Closed chakravarthi589 closed 5 years ago
The example never stops. Please have it stop after 360 degrees.
Remove #include
Make the window a little bigger, say 640, 480.
Tnanks
Also in VTKExamples/src/Cxx
there is a file called .clang-format
that specifies the formatting for the Kitware standard formatting for C++. If you don't know how to use clang-format
or it is not built in to your editor, I can fix the formatting once it is merged.
@lorensen . @ajpmaclean:
I have enabled the built in clang-format in my editor. but am not sure whether the formatting is as expected.
Please review.
For some reason your indentation seems to be 8 spaces instead of two spaces, so the formatting is not correct, I don' t think it picked up the .clang-format file. Please refer to Guidelines and look at existing examples.
@ajpmaclean : I'll try again to fix the indentation issue.
Is this fine now ?
#include <vtkAnimationScene.h>
? I don't see it being used anywhere in the code.clang-format
and use the supplied .clang-format
to easily format your code if your editor is not supporting it. See Clang 9 documentation for how to use it. It is worth setting up!Please review now. I've followed your inputs.
You need to re-run ctest as the images are different.
Image differencing failed to produce an image because images are different size:
Valid image: 230, 229, 1
Test image: 640, 480, 1
<DartMeasurement name="WallTime" type="numeric/double">0.35</DartMeasurement>
<DartMeasurement name="CPUTime" type="numeric/double">0.351</DartMeasurement>
<end of output>
Test time = 5.62 sec
There may be a problem with your formatting, when I run clang-format -i RotatingSphere.cxx
I get:
#include <vtkActor.h>
#include <vtkNamedColors.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
class vtkTimerCallback2 : public vtkCommand
{
public:
int timerId;
static vtkTimerCallback2* New()
{
vtkTimerCallback2* cb = new vtkTimerCallback2;
cb->TimerCount = 0;
return cb;
}
virtual void Execute(vtkObject* caller, unsigned long eventId,
void* vtkNotUsed(callData))
{
vtkRenderWindowInteractor* iren =
dynamic_cast<vtkRenderWindowInteractor*>(caller);
if (vtkCommand::TimerEvent == eventId)
{
++this->TimerCount;
}
if (TimerCount < 36)
{
actor->RotateZ(5);
iren->GetRenderWindow()->Render();
}
else
{
iren->DestroyTimer();
}
}
private:
int TimerCount;
public:
vtkActor* actor;
};
int main(int, char* [])
{
vtkSmartPointer<vtkNamedColors> colors =
vtkSmartPointer<vtkNamedColors>::New();
// Create a sphere
vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
sphereSource->SetCenter(0.0, 0.0, 0.0);
sphereSource->SetRadius(1.0);
sphereSource->SetThetaResolution(15);
sphereSource->SetPhiResolution(15);
sphereSource->Update();
// Create a mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(sphereSource->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->RotateX(90);
actor->GetProperty()->SetRepresentationToWireframe();
// Create a renderer, render window, and interactor
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
renderWindow->SetSize(640, 480);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
// Add the actor to the scene
renderer->AddActor(actor);
renderer->SetBackground(colors->GetColor3d("Seashell").GetData());
// Render and interact
renderWindow->Render();
// Initialize must be called prior to creating timer events.
renderWindowInteractor->Initialize();
// Sign up to receive TimerEvent
vtkSmartPointer<vtkTimerCallback2> cb =
vtkSmartPointer<vtkTimerCallback2>::New();
cb->actor = actor;
renderWindowInteractor->AddObserver(vtkCommand::TimerEvent, cb);
int timerId = renderWindowInteractor->CreateRepeatingTimer(100);
cb->timerId = timerId;
// Start the interaction and timer
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
@ajpmaclean : Please review now.
Looking good! Thanks. These examples showcase VTK and must inspire, so the images must look good and the code formatting has to be consistent.
@ajpmaclean: Thank you for your inputs and valuable time to review the examples. Such great work by you and @lorensen. VTK is helping a lot of users like me to learn visualization concepts very effectively.
@ajpmaclean : Please review.