35 #if defined (HAVE_CONFIG_H) 50 #define CONTOUR_QUANT 50 94 double lvl,
int r,
int c,
double ct_x,
double ct_y,
97 double px[4], py[4], pz[4],
tmp;
98 unsigned int stop_edge, pt[2];
101 while (r >= 0 &&
c >= 0 && r < mark.
rows () &&
c < mark.
cols ()
106 px[0] = px[3] = X(
c);
107 px[1] = px[2] = X(
c+1);
109 py[0] = py[1] = Y(r);
110 py[2] = py[3] = Y(r+1);
112 pz[3] =
Z(r+1,
c) - lvl;
113 pz[2] =
Z(r+1,
c + 1) - lvl;
114 pz[1] =
Z(r,
c+1) - lvl;
115 pz[0] =
Z(r,
c) - lvl;
126 char id =
static_cast<char> (mark(r,
c));
129 if (start_edge == 255)
132 for (
unsigned int k = 0;
k < 4;
k++)
133 if (static_cast<char> (1 <<
k) &
id)
137 if (start_edge == 255)
141 mark(r,
c) -=
static_cast<char> (1 << start_edge);
145 pt[1] = (pt[0] + 1) % 4;
150 tmp = fabs (pz[pt[1]]) / fabs (pz[pt[0]]);
156 ct_x = px[pt[0]] + (px[pt[1]] - px[pt[0]])/(1 +
tmp);
157 ct_y = py[pt[0]] + (py[pt[1]] - py[pt[0]])/(1 +
tmp);
166 for (
unsigned int k = 1;
k <= 4;
k++)
168 if (start_edge == 0 || start_edge == 2)
169 stop_edge = (start_edge +
k) % 4;
171 stop_edge = (start_edge -
k) % 4;
173 if (static_cast<char> (1 << stop_edge) &
id)
178 pt[1] = (pt[0] + 1) % 4;
179 tmp = fabs (pz[pt[1]]) / fabs (pz[pt[0]]);
185 ct_x = px[pt[0]] + (px[pt[1]] - px[pt[0]])/(1 +
tmp);
186 ct_y = py[pt[0]] + (py[pt[1]] - py[pt[0]])/(1 +
tmp);
193 mark(r,
c) -=
static_cast<char> (1 << stop_edge);
198 else if (stop_edge == 1)
200 else if (stop_edge == 2)
202 else if (stop_edge == 3)
206 start_edge = (stop_edge + 2) % 4;
214 unsigned int nr = mark.
rows ();
215 unsigned int nc = mark.
cols ();
219 for (
unsigned int c = 0;
c < nc;
c++)
220 for (
unsigned int r = 0; r < nr; r++)
222 f[0] =
Z(r,
c) - lvl;
223 f[1] =
Z(r,
c+1) - lvl;
224 f[3] =
Z(r+1,
c) - lvl;
225 f[2] =
Z(r+1,
c+1) - lvl;
227 for (
unsigned int i = 0;
i < 4;
i++)
228 if (fabs(
f[
i]) < std::numeric_limits<double>::epsilon ())
229 f[
i] = std::numeric_limits<double>::epsilon ();
238 for (
unsigned int r = 0; r < nr; r++)
239 for (
unsigned int c = 0;
c < nc;
c++)
241 f[0] =
Z(r,
c) - lvl;
242 f[1] =
Z(r,
c+1) - lvl;
243 f[3] =
Z(r+1,
c) - lvl;
244 f[2] =
Z(r+1,
c+1) - lvl;
246 for (
unsigned int i = 0;
i < 4;
i++)
247 if (fabs(
f[
i]) < std::numeric_limits<double>::epsilon ())
248 f[
i] = std::numeric_limits<double>::epsilon ();
261 unsigned int nr =
Z.rows ();
262 unsigned int nc =
Z.cols ();
270 for (
unsigned int c = 0;
c < nc - 1;
c++)
274 drawcn (X, Y,
Z, lvl, 0,
c, 0.0, 0.0, 0,
true, mark);
277 if (mark(nr - 2,
c) & 4)
278 drawcn (X, Y,
Z, lvl, nr - 2,
c, 0.0, 0.0, 2,
true, mark);
281 for (
unsigned int r = 0; r < nr - 1; r++)
285 drawcn (X, Y,
Z, lvl, r, 0, 0.0, 0.0, 3,
true, mark);
288 if (mark(r, nc - 2) & 2)
289 drawcn (X, Y,
Z, lvl, r, nc - 2, 0.0, 0.0, 1,
true, mark);
292 for (
unsigned int r = 0; r < nr - 1; r++)
293 for (
unsigned int c = 0;
c < nc - 1;
c++)
295 drawcn (X, Y,
Z, lvl, r,
c, 0.0, 0.0, 255,
true, mark);
298 DEFUN (__contourc__, args, ,
304 if (args.length () != 4)
307 RowVector X = args(0).row_vector_value ();
308 RowVector Y = args(1).row_vector_value ();
309 Matrix Z = args(2).matrix_value ();
310 RowVector L = args(3).row_vector_value ();
314 for (
int i = 0;
i < L.
numel ();
i++)
octave_idx_type rows(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
static Matrix this_contour
OCTINTERP_API void print_usage(void)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Z
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
static void start_contour(double lvl, double x, double y)
octave_idx_type cols(void) const
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit first
Matrix append(const Matrix &a) const
static void cntr(const RowVector &X, const RowVector &Y, const Matrix &Z, double lvl)
static void drawcn(const RowVector &X, const RowVector &Y, const Matrix &Z, double lvl, int r, int c, double ct_x, double ct_y, unsigned int start_edge, bool first, charMatrix &mark)
static void end_contour(void)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
static void mark_facets(const Matrix &Z, charMatrix &mark, double lvl)
the element is set to zero In other the statement xample y
static void add_point(double x, double y)
Matrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
octave_idx_type numel(void) const
Number of elements in the array.
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x