I'm hit (again) by this sort of error.
I am trying to produce some C++ code inspired by:
Handle(V3d_Viewer) theViewer;
Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (theViewer);
BRepPrimAPI_MakeWedge aWedgeMaker (theWedgeDX, theWedgeDY, theWedgeDZ, theWedgeLtx);
TopoDS_Solid aShape = aWedgeMaker.Solid();
Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShape); // creation of the presentable object
aContext->Display (aShapePrs, AIS_Shaded, 0, true); // display the presentable object and redraw 3d viewer
The nim code I am using is here:
import occt
proc main =
var box = newBRepPrimAPI_MakeBox(1.0, 2.0, 3.0)
box.build()
var solid:TopoDS_Solid = box.solid()
if solid.isNull:
raise newException(ValueError, "Can't export null shape to STEP")
var aShapePrs:HandleAIS_Shape = cnew newAIS_Shape(solid)
# Viewer
var theViewer:HandleV3dViewer
var aContext:HandleAIS_InteractiveContext = cnew newAIS_InteractiveContext(theViewer) # HandleAISInteractiveContext
main()
This produces something like:
typedef opencascade::handle<AIS_Shape> TY__6bYeLZ8jjoTd3pKksn4PZg;
typedef opencascade::handle<V3d_Viewer> TY__hV9coJYj09bB7uTcoH1nAK8A;
typedef opencascade::handle<AIS_InteractiveContext> TY__vYgPWUSvHEqxRd4NbcK4Ww;
...
TY__hV9coJYj09bB7uTcoH1nAK8A theViewer;
BRepPrimAPI_MakeBox box(1.0f, 2.0f, 3.0f);
box.Build();
TopoDS_Solid solid = box.Solid();
{
tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw* T5_;
NimStringDesc* T6_;
if (!solid.IsNull()) goto LA3_;
{ T5_ = (tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw*)0;
T5_ = (tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw*) newObj((&NTIrefvalueerror__Ie1m0dv1ZHg72IgPRr1cDw_), sizeof(tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw));
(*T5_).m_type = (&NTIvalueerror__yoNlBGx0D2tRizIdhQuENw_);
(*T5_).name = "ValueError";
T6_ = (NimStringDesc*)0;
T6_ = (*T5_).message; (*T5_).message = copyStringRC1(((NimStringDesc*) &TM__hQf24gxNvlgjncWEA40Lhg_2));
if (T6_) nimGCunrefNoCycle(T6_);
asgnRef((void**) (&(*T5_).parent), ((Exception*) NIM_NIL));
raiseExceptionEx((Exception*)T5_, "ValueError", "main", "viewer01.nim", 8);
} }
LA3_: ;
TY__6bYeLZ8jjoTd3pKksn4PZg aShapePrs = ((new AIS_Shape(solid)));
theViewer.m_type = (&NTIhandle__hV9coJYj09bB7uTcoH1nAK8A_);
TY__vYgPWUSvHEqxRd4NbcK4Ww aContext = ((new AIS_InteractiveContext(theViewer)));
The issue is with the line:
theViewer.m_type = (&NTIhandle__hV9coJYj09bB7uTcoH1nAK8A_);
that I don't know how to avoid it. It produces the error:
has no member named ‘m_type’
I am using header instead of dynlib.
HandleV3dViewer is defined here.
@carterza, I am not sure I understand what you are saying. I importcpp both Handle and V3dViewer. I define HandleV3dViewer as HandleV3dViewer* = Handle[V3dViewer]. So later, in the code, I would expect that the following:
var theViewer:HandleV3dViewer
gets converted into:
typedef opencascade::handle<V3d_Viewer> TY__hV9coJYj09bB7uTcoH1nAK8A;
...
TY__hV9coJYj09bB7uTcoH1nAK8A theViewer;
I don't see the need for the line:
theViewer.m_type = (&NTIhandle__hV9coJYj09bB7uTcoH1nAK8A_);
So part of the issue was that I was mixing = object of RootObj and {.pure, inheritable.}.
But now I am having the following issue. I have:
type
NCollectionHandle*[T] {.importcpp: "NCollection_Handle<\'0>",
header: "NCollection_Handle.hxx", bycopy.} = object of HandleStandardTransient
When I compile this, I get the error:
Error: inheritance only works with non-final objects; for HandleStandardTransient to be inheritable it must be 'object of RootObj' instead of 'object'
The way in which I have define this is:
type
Handle*[T] {.importcpp: "opencascade::handle<\'0>",
header: "Standard_Handle.hxx", bycopy, pure, inheritable.} = object
[...]
type
StandardTransient* {.importcpp: "Standard_Transient",
header: "Standard_Transient.hxx", bycopy, pure, inheritable.} = object
[...]
type
HandleStandardTransient* = Handle[StandardTransient]
If I remove pure,inheritable from StandardTransient, it stops from complaining on NCollectionHandle, but then it starts complaining on:
type
Graphic3dShaderProgram* {.importcpp: "Graphic3d_ShaderProgram",
header: "Graphic3d_ShaderProgram.hxx", bycopy.} = object of StandardTransient
because obviously StandardTransient stops being inheritable.
What would be the proper way to mark it as inheritable?
Seems to be solved by doing:
type
HandleStandardTransient* {.importcpp: "opencascade::handle<Standard_Transient>",
header: "Standard_Transient.hxx", byref, pure,inheritable.} = object
instead of:
type
HandleStandardTransient* = Handle[StandardTransient]
But I still wonder why this last one doesn't work.