From: Eduardo DAVILA Date: Tue, 15 Oct 2019 12:58:50 +0000 (+0200) Subject: #3316 creaVtk Feature New Normal - VoiMPR box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=41daf9a2fe50ac564d81e47912feca820eef1b9f;p=creaVtk.git #3316 creaVtk Feature New Normal - VoiMPR box --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkVoiMPR.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkVoiMPR.cxx new file mode 100644 index 0000000..3e89bb7 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkVoiMPR.cxx @@ -0,0 +1,250 @@ +//===== +// 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 "bbcreaVtkVoiMPR.h" +#include "bbcreaVtkPackage.h" + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,VoiMPR) +BBTK_BLACK_BOX_IMPLEMENTATION(VoiMPR,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 VoiMPR::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 = " < vecP = bbGetInputIn(); + int dep; + std::vector vecPoint = bbGetInputActualPoint(); + if (vecPoint.size()==3) + { + if ((vecPoint[0]>=vecP[0]) && (vecPoint[0]<=vecP[1]) ) + { + showActorYZ=bbGetInputActive() && true; + } else { + showActorYZ=bbGetInputActive() && false; + } + if ((vecPoint[1]>=vecP[2]) && (vecPoint[1]<=vecP[3]) ) + { + showActorXZ=bbGetInputActive() && true; + } else { + showActorXZ=bbGetInputActive() && false; + } + if ((vecPoint[2]>=vecP[4]) && (vecPoint[2]<=vecP[5]) ) + { + showActorXY=bbGetInputActive() && true; + } else { + showActorXY=bbGetInputActive() && false; + } + + } else { + showActorXY=bbGetInputActive(); + showActorYZ=bbGetInputActive(); + showActorXZ=bbGetInputActive(); + } + + if (bbGetInputXYrender()!=NULL) + { + dep=-900; + pointsXY->SetPoint(0, vecP[0], vecP[2], dep); + pointsXY->SetPoint(1, vecP[0], vecP[3], dep); + pointsXY->SetPoint(2, vecP[1], vecP[3], dep); + pointsXY->SetPoint(3, vecP[1], vecP[2], dep); + pointsXY-> Modified(); + if ( showActorXY==true ) + { + if (actorAddedXY==false) + { + bbGetInputXYrender()->AddActor(polygonActorXY); + actorAddedXY=true; + } // + } else { + if (actorAddedXY==true) + { + bbGetInputXYrender()->RemoveActor(polygonActorXY); + actorAddedXY=false; + } // + }// Active + } // if XYrender + if (bbGetInputYZrender()!=NULL) + { + dep=900; + pointsYZ->SetPoint(0, dep,vecP[2], vecP[4] ); + pointsYZ->SetPoint(1, dep,vecP[2], vecP[5] ); + pointsYZ->SetPoint(2, dep,vecP[3], vecP[5] ); + pointsYZ->SetPoint(3, dep,vecP[3], vecP[4] ); + pointsYZ-> Modified(); + if ( showActorYZ==true ) + { + if (actorAddedYZ==false) + { + bbGetInputYZrender()->AddActor(polygonActorYZ); + actorAddedYZ=true; + } // + } else { + if (actorAddedYZ==true) + { + bbGetInputYZrender()->RemoveActor(polygonActorYZ); + actorAddedYZ=false; + } // + }// Active + } // if XYrender + if (bbGetInputXZrender()!=NULL) + { + dep=-900; + pointsXZ->SetPoint(0, vecP[0],dep, vecP[4] ); + pointsXZ->SetPoint(1, vecP[0],dep, vecP[5] ); + pointsXZ->SetPoint(2, vecP[1],dep, vecP[5] ); + pointsXZ->SetPoint(3, vecP[1],dep, vecP[4] ); + pointsXZ-> Modified(); + if ( showActorXZ==true ) + { + if (actorAddedXZ==false) + { + bbGetInputXZrender()->AddActor(polygonActorXZ); + actorAddedXZ=true; + } // + } else { + if (actorAddedXZ==true) + { + bbGetInputXZrender()->RemoveActor(polygonActorXZ); + actorAddedXZ=false; + } // + }// Active + } // if XYrender + } // In size +} +//===== +// 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 VoiMPR::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + actorAddedXY=false; + actorAddedXZ=false; + actorAddedYZ=false; + bbSetInputActive(true); + bbSetInputXYrender(NULL); + bbSetInputYZrender(NULL); + bbSetInputXZrender(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 VoiMPR::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + pointsXY = vtkPoints ::New(); + linesXY = vtkCellArray ::New(); + polygonXY = vtkPolyData ::New(); + polygonMapperXY = vtkPolyDataMapper ::New(); + polygonActorXY = vtkActor ::New(); + pointsXY -> SetNumberOfPoints(4); + pointsXY -> SetPoint(0, 0, 0, 0); + pointsXY -> SetPoint(1, 0, 0, 0); + pointsXY -> SetPoint(2, 0, 0, 0); + pointsXY -> SetPoint(3, 0, 0, 0); + linesXY -> InsertNextCell(5); + linesXY -> InsertCellPoint(0); + linesXY -> InsertCellPoint(1); + linesXY -> InsertCellPoint(2); + linesXY -> InsertCellPoint(3); + linesXY -> InsertCellPoint(0); + polygonXY -> SetPoints(pointsXY); + polygonXY -> SetLines(linesXY); + polygonMapperXY -> SetInputData(polygonXY); + polygonMapperXY -> Update(); + polygonActorXY -> SetMapper(polygonMapperXY); + + + pointsXZ = vtkPoints ::New(); + linesXZ = vtkCellArray ::New(); + polygonXZ = vtkPolyData ::New(); + polygonMapperXZ = vtkPolyDataMapper ::New(); + polygonActorXZ = vtkActor ::New(); + pointsXZ -> SetNumberOfPoints(4); + pointsXZ -> SetPoint(0, 0, 0, 0); + pointsXZ -> SetPoint(1, 0, 0, 0); + pointsXZ -> SetPoint(2, 0, 0, 0); + pointsXZ -> SetPoint(3, 0, 0, 0); + linesXZ -> InsertNextCell(5); + linesXZ -> InsertCellPoint(0); + linesXZ -> InsertCellPoint(1); + linesXZ -> InsertCellPoint(2); + linesXZ -> InsertCellPoint(3); + linesXZ -> InsertCellPoint(0); + polygonXZ -> SetPoints(pointsXZ); + polygonXZ -> SetLines(linesXZ); + polygonMapperXZ -> SetInputData(polygonXZ); + polygonMapperXZ -> Update(); + polygonActorXZ -> SetMapper(polygonMapperXZ); + + pointsYZ = vtkPoints ::New(); + linesYZ = vtkCellArray ::New(); + polygonYZ = vtkPolyData ::New(); + polygonMapperYZ = vtkPolyDataMapper ::New(); + polygonActorYZ = vtkActor ::New(); + pointsYZ ->SetNumberOfPoints(4); + pointsYZ ->SetPoint(0, 0, 0, 0); + pointsYZ ->SetPoint(1, 0, 0, 0); + pointsYZ ->SetPoint(2, 0, 0, 0); + pointsYZ ->SetPoint(3, 0, 0, 0); + linesYZ ->InsertNextCell(5); + linesYZ ->InsertCellPoint(0); + linesYZ ->InsertCellPoint(1); + linesYZ ->InsertCellPoint(2); + linesYZ ->InsertCellPoint(3); + linesYZ ->InsertCellPoint(0); + polygonYZ -> SetPoints(pointsYZ); + polygonYZ -> SetLines(linesYZ); + polygonMapperYZ -> SetInputData(polygonYZ); + polygonMapperYZ -> Update(); + polygonActorYZ -> SetMapper(polygonMapperYZ); +} +//===== +// 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 VoiMPR::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkVoiMPR.h b/bbtk_creaVtk_PKG/src/bbcreaVtkVoiMPR.h new file mode 100644 index 0000000..b5f4c8a --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkVoiMPR.h @@ -0,0 +1,89 @@ +//===== +// 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 __bbcreaVtkVoiMPR_h_INCLUDED__ +#define __bbcreaVtkVoiMPR_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkPoints.h" +#include "vtkCellArray.h" +#include "vtkPolyData.h" +#include "vtkPolyDataMapper.h" +#include "vtkActor.h" +#include "vtkRenderer.h" + + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT VoiMPR + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(VoiMPR,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,std::vector); + BBTK_DECLARE_INPUT(ActualPoint,std::vector); + BBTK_DECLARE_INPUT(XYrender,vtkRenderer*); + BBTK_DECLARE_INPUT(YZrender,vtkRenderer*); + BBTK_DECLARE_INPUT(XZrender,vtkRenderer*); + BBTK_DECLARE_INPUT(Active,bool); +// BBTK_DECLARE_OUTPUT(Out,double); + BBTK_PROCESS(Process); + void Process(); + + vtkPoints *pointsXY; + vtkCellArray *linesXY; + vtkPolyData *polygonXY; + vtkPolyDataMapper *polygonMapperXY; + vtkActor *polygonActorXY; + bool actorAddedXY; + + vtkPoints *pointsXZ; + vtkCellArray *linesXZ; + vtkPolyData *polygonXZ; + vtkPolyDataMapper *polygonMapperXZ; + vtkActor *polygonActorXZ; + bool actorAddedXZ; + + + vtkPoints *pointsYZ; + vtkCellArray *linesYZ; + vtkPolyData *polygonYZ; + vtkPolyDataMapper *polygonMapperYZ; + vtkActor *polygonActorYZ; + bool actorAddedYZ; + +//===== +// 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(VoiMPR,bbtk::AtomicBlackBox); + BBTK_NAME("VoiMPR"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + + BBTK_INPUT(VoiMPR,In,"input box (minX maxX minY maxY minZ maxZ)",std::vector,""); + BBTK_INPUT(VoiMPR,ActualPoint,"Actual point [x y z]",std::vector,""); + BBTK_INPUT(VoiMPR,XYrender,"vtkRenderer XY",vtkRenderer*,""); + BBTK_INPUT(VoiMPR,YZrender,"vtkRenderer YZ",vtkRenderer*,""); + BBTK_INPUT(VoiMPR,XZrender,"vtkRenderer XZ",vtkRenderer*,""); + BBTK_INPUT(VoiMPR,Active,"(default true) Visible true / Not visible false",bool,""); +// BBTK_OUTPUT(VoiMPR,Out,"First output",double,""); + +BBTK_END_DESCRIBE_BLACK_BOX(VoiMPR); +//===== +// 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 bbcreaVtk + +#endif // __bbcreaVtkVoiMPR_h_INCLUDED__ +