Here is a 3D object lock from Create Lock By Blender.
We can use vtkPolyDataSilhouette to extract a subset of a polygonal mesh edges to generate an outline (silhouette).

#include <iostream>
#include <vector>

#include <iostream>
#include <vtkPolyData.h>
#include <vtkProperty.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkPlane.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPoints.h>
#include <vtkPolyDataSilhouette.h>
#include <vtkSTLReader.h>

#include "./point.hpp"
#include <vtkPlane.h>
#include <vtkPlaneSource.h>
#include <vtkTransform.h>

#define vtkSPtr vtkSmartPointer
#define vtkSPtrNew(Var, Type) vtkSPtr<Type> Var = vtkSPtr<Type>::New();

int main()
{
    vtkSPtrNew( reader, vtkSTLReader );
    reader->SetFileName( "C:/Users/StephenWei/Desktop/locker.stl" );
    reader->Update();

    vtkSPtrNew( renderer, vtkRenderer );

    vtkSPtrNew( renderWindow, vtkRenderWindow );
    renderWindow->AddRenderer( renderer );
    renderWindow->Render();

    vtkSPtrNew( silhouette, vtkPolyDataSilhouette );
    silhouette->SetInputData( reader->GetOutput() );
    silhouette->SetCamera( renderer->GetActiveCamera() );
    silhouette->SetEnableFeatureAngle(0);
    silhouette->Update();

    vtkSPtrNew( mapper, vtkPolyDataMapper );
    mapper->SetInputData( silhouette->GetOutput() );

    vtkSPtrNew( actor, vtkActor );
    actor->SetMapper( mapper );

    renderer->AddActor( actor );
    renderer->SetBackground( 0, 0, 0 );
    renderer->ResetCamera();

    vtkSPtrNew( renderWindowInteractor, vtkRenderWindowInteractor );
    renderWindowInteractor->SetRenderWindow( renderWindow );

    renderWindowInteractor->Start();

    return 0;
}

Result:

Categories: VTK

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x