I got a problem when trying to triangulating a 3D solid entity.
To triangulate the 3D entity, I used the acdbGetObjectMesh() metho from RealDWG lib 2013. Here is the document on this method: http://docs.autodesk.com/ACDMAC/2011/ENU/ObjectARX%20Reference/index.html?frmname=topic&frmfile=acdb...
I also found two examples using this method:
http://forums.autodesk.com/t5/objectarx/how-to-facet-acdbsubdmesh-objects/td-p/3438699
Below is my code:
jobject create3dSolid(JNIEnv* env, jobject& tempRecord, AcDbEntity *pEntity) { AcDbFaceterSettings faceter; AcGePoint3dArray vertexArray; AcArray<Adesk::Int32> faceArray; AcGiFaceData* faceData; //pEntity is pointing to an AcDb3dSolid object. Acad::ErrorStatus es = acdbGetObjectMesh(pEntity, &faceter, vertexArray, faceArray, faceData); if (es == Acad::eOk) { cerr << "OK.\n"; cerr << vertexArray.length() << endl; cerr << faceArray.length() << endl; } if (faceData) { cerr << "faceData is not NULL. \n"; } cerr << "Just before return \n"; return NULL; }
Below is console output when above code is run:
8 30 Just before return
The code crashes just after outputting “Just before return”. According to my debugging, it crashes when faceArray is being destroyed.
Visual Studio 2010 also pops up dialogs including messages as below:
Expressio: _CrtlsValidHeapPointer(pUserData) Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) HEAP CORRUPTION DETECTED: before Free block(#771469516) at ... HEAP CORRUPTION DETECTED: after Free block(#771469516) at ...
I've spent a couple of days on this problem. Could you give me some ideas on fixing it?
Thanks,
Jeffrey
Solved! Go to Solution.
Solved by Jeffrey.Tian. Go to Solution.
You need to initialize faceter and you should initialize faceData to NULL before calling the acdbGetObjectMesh() function.
Thank you.
One of my coworkers told me the same way as you suggested, but it didn't work.
I initialized faceter and faceData as below and I got the similar issue:
AcDbFaceterSettings faceter = {0.001, 0.001, 10, 1000, 1000, 3, 3, 2}; AcGePoint3dArray vertexArray; AcArray<Adesk::Int32> faceArray; AcGiFaceData* faceData = NULL; Acad::ErrorStatus es = acdbGetObjectMesh(pEntity, &faceter, vertexArray, faceArray, faceData);
You'll need to provide sample code to reproduce the problem, as this code works fine for me in AutoCAD 2015.
I just solved the probem.
My project is a DLL project and the DLL file is called by a Java application.
This moring, I happend to find this article : http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CPP/Q_21804947.html
It says MSVCRT.lib should be added to linker because DLL is mixed-mode.
I followed its instruction and fixed the problem.
What I did is: In the Property Pages dialog box, click Linker, click Input., and then add msvcrt.lib to the Additional Dependencies property.
Jeffrey