2 // 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)
4 #include "bbcreaVtkMeshCutByAxis.h"
5 #include "bbcreaVtkPackage.h"
9 #include <vtkClipPolyData.h>
14 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MeshCutByAxis)
15 BBTK_BLACK_BOX_IMPLEMENTATION(MeshCutByAxis,bbtk::AtomicBlackBox);
17 // 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)
19 void MeshCutByAxis::Process()
22 // THE MAIN PROCESSING METHOD BODY
23 // Here we simply set the input 'In' value to the output 'Out'
24 // And print out the output value
25 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
26 // void bbSet{Input|Output}NAME(const TYPE&)
27 // const TYPE& bbGet{Input|Output}NAME() const
29 // * NAME is the name of the input/output
30 // (the one provided in the attribute 'name' of the tag 'input')
31 // * TYPE is the C++ type of the input/output
32 // (the one provided in the attribute 'type' of the tag 'input')
34 // bbSetOutputOut( bbGetInputIn() );
35 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
39 vtkPlane *clipPlane = vtkPlane::New();
40 vtkBox *clipBox = vtkBox::New();
41 vtkClipPolyData *clipper = vtkClipPolyData::New();
42 //EED 2017-01-01 Migration VTK7
43 #if VTK_MAJOR_VERSION <= 5
44 clipper -> SetInput( bbGetInputIn() );
46 clipper -> SetInputData( bbGetInputIn() );
48 clipper->SetInsideOut( bbGetInputInsideVol() );
50 int a; // correction border
51 if (bbGetInputInsideVol()==false)
58 int px=bbGetInputPoint()[0];
59 int py=bbGetInputPoint()[1];
60 int pz=bbGetInputPoint()[2];
62 if ( bbGetInputType()=="x" ) { clipPlane->SetNormal(1, 0, 0); ok=1; } else
63 if ( bbGetInputType()=="y" ) { clipPlane->SetNormal(0, 1, 0); ok=1; } else
64 if ( bbGetInputType()=="z" ) { clipPlane->SetNormal(0, 0, 1); ok=1; } else
66 if ( bbGetInputType()=="x+y+" ) { clipBox->SetBounds(px ,px+sb ,py ,py+sb ,pz-sb ,pz+sb ); ok=2; } else
67 if ( bbGetInputType()=="x-y+" ) { clipBox->SetBounds(px-sb,px+a ,py ,py+sb ,pz-sb ,pz+sb ); ok=2; } else
68 if ( bbGetInputType()=="x+y-" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+a ,pz-sb ,pz+sb ); ok=2; } else
69 if ( bbGetInputType()=="x-y-" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+a ,pz-sb ,pz+sb ); ok=2; } else
71 if ( bbGetInputType()=="y+z+" ) { clipBox->SetBounds(px-sb,px+sb ,py ,py+sb ,pz ,pz+sb ); ok=2; } else
72 if ( bbGetInputType()=="y-z+" ) { clipBox->SetBounds(px-sb,px+sb ,py-sb ,py+a ,pz ,pz+sb ); ok=2; } else
73 if ( bbGetInputType()=="y+z-" ) { clipBox->SetBounds(px-sb,px+sb ,py ,py+sb ,pz-sb ,pz+a ); ok=2; } else
74 if ( bbGetInputType()=="y-z-" ) { clipBox->SetBounds(px-sb,px+sb ,py-sb ,py+a ,pz-sb ,pz+a ); ok=2; } else
76 if ( bbGetInputType()=="x+z+" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+sb ,pz ,pz+sb ); ok=2; } else
77 if ( bbGetInputType()=="x-z+" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+sb ,pz ,pz+sb ); ok=2; } else
78 if ( bbGetInputType()=="x+z-" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+sb ,pz-sb ,pz+a ); ok=2; } else
79 if ( bbGetInputType()=="x-z-" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+sb ,pz-sb ,pz+a ); ok=2; } else
82 if ( bbGetInputType()=="x+y+z+" ) { clipBox->SetBounds(px ,px+sb ,py ,py+sb ,pz ,pz+sb ); ok=2; } else
83 if ( bbGetInputType()=="x-y+z+" ) { clipBox->SetBounds(px-sb,px+a ,py ,py+sb ,pz ,pz+sb ); ok=2; } else
84 if ( bbGetInputType()=="x+y-z+" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+a ,pz ,pz+sb ); ok=2; } else
85 if ( bbGetInputType()=="x+y+z-" ) { clipBox->SetBounds(px ,px+sb ,py ,py+sb ,pz-sb ,pz+a ); ok=2; } else
86 if ( bbGetInputType()=="x-y-z+" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+a ,pz ,pz+sb ); ok=2; } else
87 if ( bbGetInputType()=="x+y-z-" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+a ,pz-sb ,pz+a ); ok=2; } else
88 if ( bbGetInputType()=="x-y+z-" ) { clipBox->SetBounds(px-sb,px+a ,py ,py+sb ,pz-sb ,pz+a ); ok=2; } else
89 if ( bbGetInputType()=="x-y-z-" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+a ,pz-sb ,pz+a ); ok=2; }
92 clipPlane -> SetOrigin(px,py,pz);
93 clipper -> SetClipFunction(clipPlane);
94 bbSetOutputOut( clipper->GetOutput() );
97 clipper -> SetClipFunction(clipBox);
98 bbSetOutputOut( clipper->GetOutput() );
100 bbSetOutputOut( bbGetInputIn() );
104 // 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)
106 void MeshCutByAxis::bbUserSetDefaultValues()
109 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
110 // Here we initialize the input 'In' to 0
112 bbSetInputType("x+y+z+");
113 bbSetInputInsideVol(true);
114 std::vector<int> point;
118 bbSetInputPoint(point);
121 // 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)
123 void MeshCutByAxis::bbUserInitializeProcessing()
126 // THE INITIALIZATION METHOD BODY :
128 // but this is where you should allocate the internal/output pointers
134 // 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)
136 void MeshCutByAxis::bbUserFinalizeProcessing()
139 // THE FINALIZATION METHOD BODY :
141 // but this is where you should desallocate the internal/output pointers
146 // EO namespace bbcreaVtk