Sun, 10/13/2024 - 23:04
#include <V3d_Viewer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <BRepPrimAPI_MakeWedge.hxx>
#include <AIS_Shape.hxx>
int main() {
Standard_Real theWedgeDX = 30;
Standard_Real theWedgeDY = 15;
Standard_Real theWedgeDZ = 10;
Standard_Real theWedgeLtx = 5;
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
return 0;
}
Error Details :
Unhandled exception at 0x00007FFD620331B0 (TKV3d.dll) in OpenCascade.exe: 0xC0000005: Access violation reading location 0x0000000000000018.
I am a beginner. Please clarify what i am doing wrong here.
Sun, 10/13/2024 - 23:45
Hello, the issue, that your 'theViewer' is nullptr. You need to initialize viewer with platform depended code.
Best regardsm Dmitrii.
Mon, 10/14/2024 - 07:09
Thank you so much for your help again.
#include
#include
#include
#include
#include
#include
#include
int main() {
Standard_Real theWedgeDX = 30;
Standard_Real theWedgeDY = 15;
Standard_Real theWedgeDZ = 10;
Standard_Real theWedgeLtx = 5;
// create a default display connection
Handle(Aspect_DisplayConnection) aDispConnection = new Aspect_DisplayConnection();
// create a Graphic Driver
Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver(aDispConnection);
// create a Viewer to this Driver
Handle(V3d_Viewer) aViewer = new V3d_Viewer(aGraphicDriver);
// To manage graphic behaviour including selection
Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext(aViewer);
// creation of wedge.
BRepPrimAPI_MakeWedge aWedgeMaker(theWedgeDX, theWedgeDY, theWedgeDZ, theWedgeLtx);
TopoDS_Solid aShape = aWedgeMaker.Solid();
// creation of the presentable object
Handle(AIS_Shape) aShapePrs = new AIS_Shape(aShape);
// display the presentable object and redraw 3d viewer
aContext->Display(aShapePrs, AIS_Shaded, 0, true);
return 0;
}
I updated the code with your response. there are no errors i believe.
still there is no screen with a wedge. I am using this link to create screen https://dev.opencascade.org/doc/overview/html/occt_user_guides__visualization.html#occt_visu_2_1_3
Mon, 10/14/2024 - 07:34
You need also creating
V3d_View
and map it to a window (Aspect_Window
subclass depending on your system)Mon, 10/14/2024 - 10:22
Thank you. i changed the code to look like this.
and i still get this error.
Unhandled exception at 0x00007FFB5DAEFE4C in OpenCascade.exe: Microsoft C++ exception: Aspect_WindowDefinitionError at memory location 0x0000009D4A4FEF88.
Mon, 10/14/2024 - 11:11
Please check all Handle for initial value.
For example: Handle(Aspect_Window) theWindow;
Best regards, Dmitrii.
Mon, 10/14/2024 - 10:35
While copy-pasting code snippets from documentation, pay attention to
theSomething = ...
at the beginning of snippet - this is a placeholder for an object, initialized somewhere else. You're passingNULL
pointer to functions a couple of times in your code.Consider also building some existing working sample project as alternative to writing a sample from code fragments without trying to read the logic behind these snippets.
Mon, 10/14/2024 - 11:04
I am sorry. I am just trying to build one working file. so that i can breakthrough it.
Thank you.
Mon, 10/14/2024 - 11:09
The best option to check the issues during starting - build in debug mode with debug info. It will help you to investigate new tool by code analysis.
As for a first sample, indeed in the documentation have no = ...; that can lead to misunderstanding. We need to check that, I will try to plan that.
So, my recommendation - build OCCT in debug mode and check the exceptions base on stack and code details ;)
Best regards, Dmitrii.
Mon, 10/14/2024 - 11:45
Sure. Thank you.
I will improve myself and comeback soon with questions if any.