Implementing data from other classes in a Mfc Sample

HI
I have been working on developing a CAD model on OpenCASCADE. I tried to use the mfc sample TopologyBuilding with modifications for the data. I want to get data for points of the geometry from other .cpp files. So I implemented the other header and .cpp files with the sample and tried to create a point from the data.

It compiled successsfully. But when I try to execute it through a button on the window, I get the error:
"An unhandled Win32 exception occured in TopologyBuilding.exe [3292]"

Following is the code I tried to implement in TopologyBuildingDoc.cpp:

double p1 = myFuselagePt->referencePtx;
double p2 = 0.5;

BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(p1,-50,-20),gp_Pnt(-30,-60,-60));

I declared the fuselage class (the class I want to take my data from) pointer object myFuselagePt in TopologyBuildingDoc.h

Plz help me with this problem. Thanks.

Nitin Jain

Nitin's picture

Hi
I did not find any samples in which data is taken from other classes, rather all the points are defined in the same function as the geometry.

Is it possible to get data from other classes??

Forum supervisor's picture

Hi Nitin,
For sure it is possible.
Very probably pointers of your new classes are not valid.
To locate the reason of exception you may use Assertions.
Regards

Nitin's picture

Thanks for the reply. Actually I am new to opencascade. Could you give me a bit more detail on how I could use assertions to locate the reason of exception. I am compiling it in the release version. There are a lot of linking errors in the Debug mode. I have attached a file which shows the errors encountered.

Also I included header files of the new classes in stdafx.h and provided the path for the dlls and lib files in the VC++ directories. Do I need to do something else to implement the classes in the sample?

Attachments: 
Forum supervisor's picture

Assertions are not specific for Open Cascade.
You may found full information about Assertions in MSDN.
OCCT distribution is built in release mode (see ...OCC650\ros\win32\vc8\..).
All libraries are located in "lib" sub-directory and dlls - in "bin".
So, to build your sample in debug mode you may:
1) Tune the project properties/Additional library directories
2) Build OCCT in debug mode too (corresponding project files you may found at the
...OCC650\ros\adm\win32\vc* subdirectory.
Regards

Nitin's picture

Hi
I checked the MSDN site for Assertions and it says that Assert functions can only be used in the Debug mode. Is there a way to solve the issue in Release mode?

Also I tried to build the sample in the debug mode. I am still getting the following errors. I am not able to resolve them.

1> Creating library ../../Debug/TopologyBuilding.lib and object ../../Debug/TopologyBuilding.exp
1>StdAfx.obj : error LNK2019: unresolved external symbol "public: void __thiscall BRepAlgoAPI_BooleanOperation::Destroy(void)" (?Destroy@BRepAlgoAPI_BooleanOperation@@QAEXXZ) referenced in function "public: virtual __thiscall BRepAlgoAPI_BooleanOperation::~BRepAlgoAPI_BooleanOperation(void)" (??1BRepAlgoAPI_BooleanOperation@@UAE@XZ)
1>TopologyBuildingDoc.obj : error LNK2001: unresolved external symbol "public: void __thiscall BRepAlgoAPI_BooleanOperation::Destroy(void)" (?Destroy@BRepAlgoAPI_BooleanOperation@@QAEXXZ)
1>StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BRepAlgoAPI_BooleanOperation::Build(void)" (?Build@BRepAlgoAPI_BooleanOperation@@UAEXXZ)
1>TopologyBuildingDoc.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BRepAlgoAPI_BooleanOperation::Build(void)" (?Build@BRepAlgoAPI_BooleanOperation@@UAEXXZ)
1>StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual class TopTools_ListOfShape const & __thiscall BRepAlgoAPI_BooleanOperation::Generated(class TopoDS_Shape const &)" (?Generated@BRepAlgoAPI_BooleanOperation@@UAEABVTopTools_ListOfShape@@ABVTopoDS_Shape@@@Z)
1>TopologyBuildingDoc.obj : error LNK2019: unresolved external symbol "public: virtual class TopTools_ListOfShape const & __thiscall BRepAlgoAPI_BooleanOperation::Generated(class TopoDS_Shape const &)" (?Generated@BRepAlgoAPI_BooleanOperation@@UAEABVTopTools_ListOfShape@@ABVTopoDS_Shape@@@Z) referenced in function "protected: void __thiscall CTopologyBuildingDoc::OnFace(void)" (?OnFace@CTopologyBuildingDoc@@IAEXXZ)
1>StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual class TopTools_ListOfShape const & __thiscall BRepAlgoAPI_BooleanOperation::Modified(class TopoDS_Shape const &)" (?Modified@BRepAlgoAPI_BooleanOperation@@UAEABVTopTools_ListOfShape@@ABVTopoDS_Shape@@@Z)
1>TopologyBuildingDoc.obj : error LNK2001: unresolved external symbol "public: virtual class TopTools_ListOfShape const & __thiscall BRepAlgoAPI_BooleanOperation::Modified(class TopoDS_Shape const &)" (?Modified@BRepAlgoAPI_BooleanOperation@@UAEABVTopTools_ListOfShape@@ABVTopoDS_Shape@@@Z)
1>StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepAlgoAPI_BooleanOperation::IsDeleted(class TopoDS_Shape const &)" (?IsDeleted@BRepAlgoAPI_BooleanOperation@@UAEIABVTopoDS_Shape@@@Z)
1>TopologyBuildingDoc.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepAlgoAPI_BooleanOperation::IsDeleted(class TopoDS_Shape const &)" (?IsDeleted@BRepAlgoAPI_BooleanOperation@@UAEIABVTopoDS_Shape@@@Z)
1>StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual class TopTools_ListOfShape const & __thiscall BRepAlgoAPI_BooleanOperation::Modified2(class TopoDS_Shape const &)" (?Modified2@BRepAlgoAPI_BooleanOperation@@UAEABVTopTools_ListOfShape@@ABVTopoDS_Shape@@@Z)
1>TopologyBuildingDoc.obj : error LNK2001: unresolved external symbol "public: virtual class TopTools_ListOfShape const & __thiscall BRepAlgoAPI_BooleanOperation::Modified2(class TopoDS_Shape const &)" (?Modified2@BRepAlgoAPI_BooleanOperation@@UAEABVTopTools_ListOfShape@@ABVTopoDS_Shape@@@Z)
1>StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepAlgoAPI_BooleanOperation::HasModified(void)const " (?HasModified@BRepAlgoAPI_BooleanOperation@@UBEIXZ)
1>TopologyBuildingDoc.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepAlgoAPI_BooleanOperation::HasModified(void)const " (?HasModified@BRepAlgoAPI_BooleanOperation@@UBEIXZ)
1>StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepAlgoAPI_BooleanOperation::HasGenerated(void)const " (?HasGenerated@BRepAlgoAPI_BooleanOperation@@UBEIXZ)
1>TopologyBuildingDoc.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepAlgoAPI_BooleanOperation::HasGenerated(void)const " (?HasGenerated@BRepAlgoAPI_BooleanOperation@@UBEIXZ)
1>StdAfx.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepAlgoAPI_BooleanOperation::HasDeleted(void)const " (?HasDeleted@BRepAlgoAPI_BooleanOperation@@UBEIXZ)
1>TopologyBuildingDoc.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepAlgoAPI_BooleanOperation::HasDeleted(void)const " (?HasDeleted@BRepAlgoAPI_BooleanOperation@@UBEIXZ)
1>TopologyBuildingDoc.obj : error LNK2019: unresolved external symbol "public: __thiscall BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(class TopoDS_Shape const &,class TopoDS_Shape const &)" (??0BRepAlgoAPI_Fuse@@QAE@ABVTopoDS_Shape@@0@Z) referenced in function "protected: void __thiscall CTopologyBuildingDoc::OnVertex(void)" (?OnVertex@CTopologyBuildingDoc@@IAEXXZ)
1>../../Debug/TopologyBuilding.exe : fatal error LNK1120: 10 unresolved externals
1>Build log was saved at "file://c:\Programme\OpenCASCADE6.3.0\samples\standard\mfc\02_TopologySamples\02_3_TopologyBuilding\Debug\BuildLog.htm"
1>TopologyBuilding - 20 error(s), 21 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Could you provide any suggestions for the above errors. Thanks.

Nitin

Forum supervisor's picture

Dear Nitin,
Without doubt Assert functions is used only in the Debug mode.
And it is a way to start from debug mode, usually used by newcomers.
It is the most effective way to learn something.
By default all OCCT libraries as for debug as for release mode have the same names.
And VC project default settings for debug mode suppose to have libs in "libd" sub-directory and dlls in "bind" directories, which for sure are empty in public release version (see the previous post).
So you may (as I already posted)
- build OCCT in debug mode (as result empty directories will be filled) and use current setting of the sample project;
- or tune the project's "properties/Additional library" directories of your sample
(to show for linker that your libs are in "lib" directory (not in "libd")).
Regards

Nitin's picture

Hi
Well I had built OCCT in both release and debug modes. So I have all the directories (bin, bind, lib, libd) filled.
But still it gives the errors.
Thanks.

Nitin

Forum supervisor's picture

Hi,
It means (if debug version of OCCT is built successfully and corresponding libs & dlls are located at right sub-folders) that very probably you forgot to add in you project a new lib corresponding to API which you used in a modified part of the sample.
I guess that it is TKBO (not used in default project of Geometry sample) because your error messages referring to BRepAlgoAPI services.
Check it,please. If it will not help you may contact us via Contact Form http://www.opencascade.org/about/contacts/.
Regards

Nitin's picture

Hi
Thanks a lot. That was the problem. I did not include the TKBO lib file. Now its compiled successfully.

But still giving the error "Unhandlel win32 exception has occurred in TopologyBuilding.exe"

And in the debugger it is giving the exception location as this line:
double p1 = myFuselagePt->referencePtx

Following is the error:
"Unhandled exception at 0x00409249 in TopologyBuilding.exe: 0xC0000005: Access violation reading location 0xcdcdcdf5."

Sorry for these many questions but I am really stuck.
Regards
Nitin