@@ -95,15 +95,19 @@ cdef class SegmentationNormal:
95
95
is currently unable to do so.
96
96
"""
97
97
cdef cpp.SACSegmentationNormal_t * me
98
+ # cdef cpp.ModelCoefficients *coeffs
98
99
def __cinit__ (self ):
99
100
self .me = new cpp.SACSegmentationNormal_t()
101
+ # self._coeffs = None
100
102
def __dealloc__ (self ):
101
103
del self .me
104
+ # del self._coeffs
102
105
103
106
def segment (self ):
104
107
cdef cpp.PointIndices ind
105
108
cdef cpp.ModelCoefficients coeffs
106
109
self .me.segment (ind, coeffs)
110
+ # self._coeffs = coeffs
107
111
return [ind.indices[i] for i in range (ind.indices.size())],\
108
112
[coeffs.values[i] for i in range (coeffs.values.size())]
109
113
@@ -127,6 +131,41 @@ cdef class SegmentationNormal:
127
131
self .me.setEpsAngle (ea)
128
132
def set_axis (self , double ax , double ay , double az ):
129
133
mpcl_sacnormal_set_axis(deref(self .me),ax,ay,az)
134
+ def set_min_max_opening_angle (self , double min_angle , double max_angle ):
135
+ """ Set the minimum and maximum cone opening angles in radians for a cone model.
136
+ """
137
+ self .me.setMinMaxOpeningAngle(min_angle, max_angle)
138
+ def get_min_max_opening_angle (self ):
139
+ min_angle = 0.0
140
+ max_angle = 0.0
141
+ self .me.getMinMaxOpeningAngle(min_angle, max_angle)
142
+ return min_angle, max_angle
143
+
144
+
145
+ cdef class SampleConsensusModelCylinder(SegmentationNormal):
146
+
147
+ cdef cpp.SampleConsensusModelCylinder_t * me
148
+ # cdef cpp.ModelCoefficients *coeffs
149
+ def __cinit__ (self ):
150
+ self .me = new cpp.SACSegmentationNormal_t()
151
+
152
+ def get_distance_to_model (self , list model_coefficients ):
153
+ """ Compute all distances from the model. You must have already fit the model.
154
+ :return: vector of distances
155
+ """
156
+
157
+ cdef vector[double ] distances
158
+
159
+ self .me.getDistancesToModel(self ._coeffs, distances)
160
+ # def count_within_distance(self, list model_coefficients, double threshold):
161
+ # cdef cpp.ModelCoefficients coeffs
162
+ # cdef vector[float] vals = model_coefficients
163
+ # coeffs.values = vals
164
+ # #coeffs.values.resize(len(model_coefficients))
165
+ # # for i, v in enumerate(model_coefficients):
166
+ # # coeffs.value[i] = v
167
+ # return self.me.countWithinDistance(vals, threshold)
168
+
130
169
131
170
132
171
# Empirically determine strides, for buffer support.
0 commit comments