Python C ++ bindings call "access violation read location 0x00000002"?

I am using CGAL Python bindings for an alpha form .

I have 8 arrays of CGAL.Triangulations_2.Vertex objects as follows:

 In [5]: len(alphaShapeVertices) Out[5]: 8 In [6]: for i, asv in enumerate(alphaShapeVertices): ...: print i ...: print asv 0 [<CGAL.Triangulations_2.Vertex object at 0x03C423E8>, <CGAL.Triangulations_2.Vertex object at 0x03C42420>, <CGAL.Triangulations_2.Vertex object at 0x03C42458>, <CGAL.Triangulations_2.Vertex object at 0x03C42490>, <CGAL.Triangulations_2.Vertex object at 0x03C424C8>, <CGAL.Triangulations_2.Vertex object at 0x03C42500>, <CGAL.Triangulations_2.Vertex object at 0x03C42538>, <CGAL.Triangulations_2.Vertex object at 0x03C42570>, <CGAL.Triangulations_2.Vertex object at 0x03C425A8>, <CGAL.Triangulations_2.Vertex object at 0x03C425E0>, <CGAL.Triangulations_2.Vertex object at 0x03C42618>, <CGAL.Triangulations_2.Vertex object at 0x03C42650>, <CGAL.Triangulations_2.Vertex object at 0x03C42688>, <CGAL.Triangulations_2.Vertex object at 0x03C426C0>, <CGAL.Triangulations_2.Vertex object at 0x03C426F8>, <CGAL.Triangulations_2.Vertex object at 0x03C42730>, <CGAL.Triangulations_2.Vertex object at 0x03C42768>, <CGAL.Triangulations_2.Vertex object at 0x03C427A0>, <CGAL.Triangulations_2.Vertex object at 0x03C427D8>, <CGAL.Triangulations_2.Vertex object at 0x03C42810>, <CGAL.Triangulations_2.Vertex object at 0x03C42848>] 1 [<CGAL.Triangulations_2.Vertex object at 0x03C42880>, <CGAL.Triangulations_2.Vertex object at 0x03C428B8>, <CGAL.Triangulations_2.Vertex object at 0x03C428F0>, <CGAL.Triangulations_2.Vertex object at 0x03C42928>, <CGAL.Triangulations_2.Vertex object at 0x03C42960>, <CGAL.Triangulations_2.Vertex object at 0x03C42998>, <CGAL.Triangulations_2.Vertex object at 0x03C429D0>, <CGAL.Triangulations_2.Vertex object at 0x03C42A08>, <CGAL.Triangulations_2.Vertex object at 0x03C42A40>, <CGAL.Triangulations_2.Vertex object at 0x03C42A78>, <CGAL.Triangulations_2.Vertex object at 0x03C42AB0>, <CGAL.Triangulations_2.Vertex object at 0x03C42AE8>] 2 [<CGAL.Triangulations_2.Vertex object at 0x03C42B20>, <CGAL.Triangulations_2.Vertex object at 0x03C42B58>, <CGAL.Triangulations_2.Vertex object at 0x03C42B90>, <CGAL.Triangulations_2.Vertex object at 0x03C42BC8>, <CGAL.Triangulations_2.Vertex object at 0x03C42C00>, <CGAL.Triangulations_2.Vertex object at 0x03C42C38>, <CGAL.Triangulations_2.Vertex object at 0x03C42C70>, <CGAL.Triangulations_2.Vertex object at 0x03C42CA8>, <CGAL.Triangulations_2.Vertex object at 0x03C42CE0>, <CGAL.Triangulations_2.Vertex object at 0x03C42D18>, <CGAL.Triangulations_2.Vertex object at 0x03C42D50>] 3 [<CGAL.Triangulations_2.Vertex object at 0x03C42D88>, <CGAL.Triangulations_2.Vertex object at 0x03C42DC0>, <CGAL.Triangulations_2.Vertex object at 0x03C42DF8>, <CGAL.Triangulations_2.Vertex object at 0x03C42E30>, <CGAL.Triangulations_2.Vertex object at 0x03C42E68>, <CGAL.Triangulations_2.Vertex object at 0x03C42EA0>, <CGAL.Triangulations_2.Vertex object at 0x03C42ED8>, <CGAL.Triangulations_2.Vertex object at 0x03C42F10>, <CGAL.Triangulations_2.Vertex object at 0x03C42F48>, <CGAL.Triangulations_2.Vertex object at 0x03C42F80>, <CGAL.Triangulations_2.Vertex object at 0x03C42FB8>, <CGAL.Triangulations_2.Vertex object at 0x03C4D030>, <CGAL.Triangulations_2.Vertex object at 0x03C4D068>, <CGAL.Triangulations_2.Vertex object at 0x03C4D0A0>] 4 [<CGAL.Triangulations_2.Vertex object at 0x03C4D0D8>, <CGAL.Triangulations_2.Vertex object at 0x03C4D110>, <CGAL.Triangulations_2.Vertex object at 0x03C4D148>, <CGAL.Triangulations_2.Vertex object at 0x03C4D180>, <CGAL.Triangulations_2.Vertex object at 0x03C4D1B8>, <CGAL.Triangulations_2.Vertex object at 0x03C4D1F0>, <CGAL.Triangulations_2.Vertex object at 0x03C4D228>, <CGAL.Triangulations_2.Vertex object at 0x03C4D260>, <CGAL.Triangulations_2.Vertex object at 0x03C4D298>, <CGAL.Triangulations_2.Vertex object at 0x03C4D2D0>, <CGAL.Triangulations_2.Vertex object at 0x03C4D308>, <CGAL.Triangulations_2.Vertex object at 0x03C4D340>, <CGAL.Triangulations_2.Vertex object at 0x03C4D378>, <CGAL.Triangulations_2.Vertex object at 0x03C4D3B0>, <CGAL.Triangulations_2.Vertex object at 0x03C4D3E8>, <CGAL.Triangulations_2.Vertex object at 0x03C4D420>, <CGAL.Triangulations_2.Vertex object at 0x03C4D458>] 5 [<CGAL.Triangulations_2.Vertex object at 0x03C4D490>, <CGAL.Triangulations_2.Vertex object at 0x03C4D4C8>, <CGAL.Triangulations_2.Vertex object at 0x03C4D500>, <CGAL.Triangulations_2.Vertex object at 0x03C4D538>, <CGAL.Triangulations_2.Vertex object at 0x03C4D570>, <CGAL.Triangulations_2.Vertex object at 0x03C4D5A8>, <CGAL.Triangulations_2.Vertex object at 0x03C4D5E0>, <CGAL.Triangulations_2.Vertex object at 0x03C4D618>, <CGAL.Triangulations_2.Vertex object at 0x03C4D650>] 6 [<CGAL.Triangulations_2.Vertex object at 0x03C4D688>, <CGAL.Triangulations_2.Vertex object at 0x03C4D6C0>, <CGAL.Triangulations_2.Vertex object at 0x03C4D6F8>, <CGAL.Triangulations_2.Vertex object at 0x03C4D730>, <CGAL.Triangulations_2.Vertex object at 0x03C4D768>, <CGAL.Triangulations_2.Vertex object at 0x03C4D7A0>, <CGAL.Triangulations_2.Vertex object at 0x03C4D7D8>] 7 [<CGAL.Triangulations_2.Vertex object at 0x03C4D810>, <CGAL.Triangulations_2.Vertex object at 0x03C4D848>, <CGAL.Triangulations_2.Vertex object at 0x03C4D880>, <CGAL.Triangulations_2.Vertex object at 0x03C4D8B8>, <CGAL.Triangulations_2.Vertex object at 0x03C4D8F0>, <CGAL.Triangulations_2.Vertex object at 0x03C4D928>] 

I am trying to access the point() method for each object.

However, I can only do this until the second array. From the 3rd onwards, I encounter an exception.

 In [7]: alphaShapeVertices[0][0].point() Out[7]: Point_2(1.00000001401,2.90491385964e-290) In [8]: alphaShapeVertices[1][0].point() Out[8]: Point_2(3.96551377978e-164,3.05578113171e-151) In [9]: alphaShapeVertices[2][0].point() # HERE: python.exe has stopped working 

screenshot of an exception:

enter image description here

As you can see, the exception may not always be thrown in the 3rd array . In the screenshot, this happens in 7th place. I think he has something to do to allocate memory.

Debugger informs me

The first chance exception in 0x00000002 in the python.exe file is: 0xC0000005: access is the location where error 0x00000002 was detected.

If there is a handler for this exception, the program can safely continue.

I fight for days. Can someone help me why and how to fix it?



MWE

You may need to install CGAL-Python (bindings for a library of computational geometry algorithms) ( CTRL + F CGAL-Python) if you do not have one.

These clusters can be found here on pasty .

With data and library ready, run the following Python script:

 from sys import * path.append("../../cgal_package") from CGAL.Alpha_shapes_2 import * from CGAL.Triangulations_2 import Delaunay_triangulation_2 from CGAL.Kernel import * from random import * import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties import constants def Point_2_str(self): return 'Point_2'+str((self.x(), self.y())) # now we turn it into a member function Point_2.__str__ = Point_2_str def getAlphaShape(cluster): list_of_points = [Point_2(e[0], e[1]) for e in cluster] L = [] verbose = True a = Alpha_shape_2() a.make_alpha_shape(list_of_points) a.set_mode(Alpha_shape_2.Mode.REGULARIZED) a.set_alpha(1000) alpha_shape_edges = [] alpha_shape_vertices = [] for it in a.alpha_shape_edges: alpha_shape_edges.append(a.segment(it)) for it in a.alpha_shape_vertices: alpha_shape_vertices.append(it) return alpha_shape_vertices # get alpha-shape of each cluster alphaShapeVertices = [] for cluster in clusters: alphaShapeVertices.append(alphashape.getAlphaShape(cluster)) # start testing print alphaShapeVertices[0][0].point() print alphaShapeVertices[1][0].point() print alphaShapeVertices[2][0].point() print alphaShapeVertices[3][0].point() # somewhere around here the exception occurs print alphaShapeVertices[4][0].point() print alphaShapeVertices[5][0].point() print alphaShapeVertices[6][0].point() 
+1
c ++ python
source share

No one has answered this question yet.

See similar questions:

7
Arrange vertices of CONCAVE polygons in (counter) clockwise?

or similar:

1675
Why is reading strings from stdin much slower in C ++ than Python?
836
How do I find the location of my Python site directory directory?
551
Read entire ASCII file in C ++ std :: string
542
Read the file line by line using ifstream in C ++
501
How to read a large file line by line
484
C / C ++ call from Python?
457
Accessing an arbitrary element in a dictionary in Python
455
Non-blocking reading on .PIPE subprocess in python
331
How to find the source location of a Python module?
one
Reading C ++ Access Location

All Articles