//===== // 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 "bbcreaVtkGlyphPolyDataNormals.h" #include "bbcreaVtkPackage.h" #include "vtkProperty.h" #include namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,GlyphPolyDataNormals) BBTK_BLACK_BOX_IMPLEMENTATION(GlyphPolyDataNormals,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 GlyphPolyDataNormals::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') //Active bool Done //Color vector Done //Opacity 0-1 Done //Mask Ratio 1-100 Done //Type of Glyph 1-Arrow 2-Line //size of glyph Done if(bbGetInputIn() == NULL) { printf("Warnning! GlyphPolyDataNormals::Process: Missing input PolyData\n"); bbSetOutputOut( NULL ); if(bbGetInputRenderer() != NULL) { if( (actorAdded==true) && (bbGetInputActive()==true) ) { bbGetInputRenderer()->RemoveActor(normalsActor); actorAdded = false; } } // if Renderer } else if(bbGetInputRenderer() == NULL) { printf("Warnning! GlyphPolyDataNormals::Process: Missing Renderer\n"); bbSetOutputOut( NULL ); } else { //Arrow Source arrow->SetTipResolution(4); arrow->SetTipLength(0.5); arrow->SetTipRadius(0.2 * bbGetInputGlyphType()); arrow->Update(); //Mask Points ptMask->SetInputData(bbGetInputIn()); ptMask->SetOnRatio(bbGetInputMaskRatio()); ptMask->RandomModeOn(); ptMask->Update(); //Glyph glyph->SetSourceData(arrow->GetOutput()); glyph->SetInputData(ptMask->GetOutput()); glyph->Update(); //glyph->SetInputData(bbGetInputIn()); glyph->SetVectorModeToUseNormal(); glyph->SetScaleFactor(bbGetInputSize()); glyph->SetColorModeToColorByVector(); glyph->SetScaleModeToScaleByVector(); glyph->OrientOn(); //Mapper y Actor normalsMapper->SetInputData(glyph->GetOutput()); normalsActor->SetMapper(normalsMapper); normalsActor->GetProperty()->SetOpacity(bbGetInputOpacity()); normalsActor->GetProperty()->SetColor(bbGetInputColor()[0], bbGetInputColor()[1], bbGetInputColor()[2]); if(bbGetInputRenderer() != NULL) { if( (actorAdded==true) && !(bbGetInputActive()==true) ) { bbGetInputRenderer()->RemoveActor(normalsActor); actorAdded = false; } else if(bbGetInputActive() && !actorAdded) { bbGetInputRenderer()->AddActor(normalsActor); actorAdded = true; } } // if Renderer bbSetOutputOut( normalsActor ); } // if InputIn } //===== // 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 GlyphPolyDataNormals::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputIn(NULL); bbSetInputOpacity(1); bbSetInputActive(true); bbSetInputMaskRatio(10); std::vector color; color.push_back(0.0); color.push_back(0.0); color.push_back(0.5); bbSetInputColor(color); bbSetInputSize(5); bbSetInputGlyphType(1); bbSetInputRenderer(NULL); bbSetOutputOut(NULL); actorAdded = false; } //===== // 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 GlyphPolyDataNormals::bbUserInitializeProcessing() { // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers // if any arrow = vtkArrowSource::New(); ptMask = vtkMaskPoints::New(); glyph = vtkGlyph3D::New(); normalsMapper = vtkPolyDataMapper::New(); normalsActor = vtkActor::New(); } //===== // 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 GlyphPolyDataNormals::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any arrow->Delete(); ptMask->Delete(); glyph->Delete(); normalsMapper->Delete(); normalsActor->Delete(); arrow = NULL; ptMask = NULL; glyph = NULL; normalsMapper = NULL; normalsActor = NULL; } } // EO namespace bbcreaVtk