1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-07 18:30:55 +03:00
occt/samples/qt/FuncDemo/src/PointDriver.cpp
vro aff5997de8 0024665: A sample for advanced function mechanism
PRO file is added + a description of how to generate the Visual Studio projects and compile.
In addition, the sample folder is renamed to FuncDemo.

Adding 64 bit configuration to VC projects
2016-02-20 13:04:31 +03:00

55 lines
1.3 KiB
C++

// PointDriver.cpp: implementation of the PointDriver class.
//
//////////////////////////////////////////////////////////////////////
#include "PointDriver.h"
#include <Standard_GUID.hxx>
#include <TDF_Reference.hxx>
#include <TNaming_Builder.hxx>
#include <TDataStd_RealArray.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
IMPLEMENT_STANDARD_HANDLE(PointDriver,BaseDriver)
IMPLEMENT_STANDARD_RTTIEXT(PointDriver,BaseDriver)
// ID of the function driver
const Standard_GUID& PointDriver::GetID()
{
static const Standard_GUID id("E9467D43-B11D-42d3-AF10-E91B74D2A3D9");
return id;
}
// Constructor
PointDriver::PointDriver()
{
}
// Execution.
Standard_Integer PointDriver::Execute(Handle(TFunction_Logbook)& log) const
{
// Usual check...
if (Label().IsNull())
return 1;
// Take the arguments (x, y, z)
Handle(TDataStd_RealArray) arr;
if (!Label().FindAttribute(TDataStd_RealArray::GetID(), arr))
return 2;
double x = arr->Value(1);
double y = arr->Value(2);
double z = arr->Value(3);
// Make the result
TopoDS_Vertex V = BRepBuilderAPI_MakeVertex(gp_Pnt(x, y, z));
// Set the result
TNaming_Builder B(Label());
B.Generated(V);
return BaseDriver::Execute(log);
}