32
32
#include < vtkCell.h>
33
33
34
34
vtkPolyData* read_stl (char *);
35
- vtkDoubleArray * find_staircase_artifacts (vtkPolyData*, const double [3 ], double );
35
+ vtkIdList * find_staircase_artifacts (vtkPolyData*, const double [3 ], double );
36
36
vtkIdList* get_near_vertices_to_v (vtkPolyData*, int , double );
37
37
vtkDoubleArray* calc_artifacts_weight (vtkPolyData*, vtkIdList*, double , double );
38
38
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
42
42
vtkPolyData *stl, *nm, *cl, *pd;
43
43
vtkPolyDataNormals *normals;
44
44
vtkCleanPolyData *clean;
45
- vtkDoubleArray *vertices_staircase;
45
+ vtkIdList *vertices_staircase;
46
46
47
47
stl = read_stl (argv[1 ]);
48
48
@@ -58,7 +58,8 @@ int main(int argc, char *argv[])
58
58
pd = clean->GetOutput ();
59
59
pd->BuildLinks ();
60
60
61
- vertices_staircase = find_staircase_artifacts (pd, stack_orientation, 0.7 );
61
+ vertices_staircase = find_staircase_artifacts (pd, stack_orientation, atof (argv[2 ]));
62
+ calc_artifacts_weight (pd, vertices_staircase, atof (argv[3 ]), 1 );
62
63
63
64
vtkXMLPolyDataWriter *writer = vtkXMLPolyDataWriter::New ();
64
65
writer->SetInput (pd);
@@ -74,7 +75,7 @@ vtkPolyData* read_stl(char* filename) {
74
75
return stl_reader->GetOutput ();
75
76
}
76
77
77
- vtkDoubleArray * find_staircase_artifacts (vtkPolyData* pd, const double stack_orientation[3 ], double T) {
78
+ vtkIdList * find_staircase_artifacts (vtkPolyData* pd, const double stack_orientation[3 ], double T) {
78
79
/*
79
80
This function is used to find vertices at staircase artifacts, which are
80
81
those vertices whose incident faces' orientation differences are
@@ -86,7 +87,7 @@ vtkDoubleArray* find_staircase_artifacts(vtkPolyData* pd, const double stack_ori
86
87
double of, min, max;
87
88
88
89
double *ni;
89
- vtkDoubleArray *output = vtkDoubleArray ::New ();
90
+ vtkIdList *output = vtkIdList ::New ();
90
91
vtkDoubleArray *scalars = vtkDoubleArray::New ();
91
92
vtkIdList *idfaces;// idfaces = vtk.vtkIdList()
92
93
@@ -111,7 +112,7 @@ vtkDoubleArray* find_staircase_artifacts(vtkPolyData* pd, const double stack_ori
111
112
// Getting the ones which normals dot is 90°, its vertex is added to
112
113
// output
113
114
if (max - min >= T) {
114
- output->InsertNextValue (vid);
115
+ output->InsertNextId (vid);
115
116
scalars->InsertNextValue (1 );
116
117
}
117
118
else {
@@ -189,16 +190,38 @@ vtkDoubleArray* calc_artifacts_weight(vtkPolyData* pd, vtkIdList* vertices_stair
189
190
considered to calculate the weight;
190
191
bmin=0.1 - The minimun weight.
191
192
*/
193
+ double vi[3 ], vj[3 ], d, value;
194
+ int viid, vjid, nnv;
195
+ int nid = vertices_staircase->GetNumberOfIds ();
196
+ vtkIdList* near_vertices;
192
197
vtkDoubleArray* weights = vtkDoubleArray::New ();
193
198
vtkDataArray* scalars = pd->GetPointData ()->GetScalars ();
194
- double vi[ 3 ], vj[ 3 ];
195
- int viid, vjid ;
196
- int nid = vertices_staircase-> GetNumberOfIds ();
197
- for (int i=0 ; i < nid; i++) {
199
+ for ( int i= 0 ; i < pd-> GetNumberOfPoints (); i++){
200
+ weights-> InsertNextValue ( 0 ) ;
201
+ }
202
+ for (int i=0 ; i < nid; i++) {
198
203
viid = vertices_staircase->GetId (i);
204
+ pd->GetPoint (viid, vi);
205
+ near_vertices = get_near_vertices_to_v (pd, viid, tmax);
206
+ nnv = near_vertices->GetNumberOfIds ();
207
+ for (int j=0 ; j < nnv; j++){
208
+ vjid = near_vertices->GetId (j);
209
+ pd->GetPoint (vjid, vj);
210
+ d = sqrt ((vi[0 ] - vj[0 ]) * (vi[0 ] - vj[0 ])\
211
+ + (vi[1 ] - vj[1 ]) * (vi[1 ] - vj[1 ])\
212
+ + (vi[2 ] - vj[2 ]) * (vi[2 ] - vj[2 ]));
213
+ value = (1.0 - d/tmax) * (1 - bmin) + bmin;
214
+ if (value > weights->GetValue (vjid)) {
215
+ printf (" %f\n " , value);
216
+ weights->SetValue (vjid, value);
217
+ scalars->SetTuple1 (vjid, value);
218
+ }
219
+ }
199
220
}
221
+
222
+ vtkPointData* pointData = pd->GetPointData ();
223
+ pointData->SetScalars (scalars);
200
224
return weights;
201
-
202
225
}
203
226
/*
204
227
def get_near_vertices_to_v(pd, v, dmax):
0 commit comments