~ubuntu-branches/ubuntu/trusty/travis/trusty-proposed

« back to all changes in this revision

Viewing changes to src/v_cell.cpp

  • Committer: Package Import Robot
  • Author(s): Daniel Leidert
  • Date: 2014-01-18 20:07:16 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140118200716-whsmcg7fa1eyqecq
Tags: 140117-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
#include "v_config.h"
14
14
#include "v_common.h"
15
 
#include "v_cell.h"
 
15
#include "v_cell.h"
16
16
#include "tools.h"
17
17
 
18
18
/** Constructs a Voronoi cell and sets up the initial memory. */
48
48
        delete [] nu;delete [] ed;
49
49
}
50
50
 
51
 
void voronoicell_base::check_memory_for_copy(voronoicell_neighbor &vc,voronoicell_base* vb) {
52
 
        while(current_vertex_order<vb->current_vertex_order) add_memory_vorder(vc);
53
 
        for(int i=0;i<current_vertex_order;i++) while(mem[i]<vb->mec[i]) add_memory(vc,i,ds2);
54
 
        while(current_vertices<vb->p) add_memory_vertices(vc);
55
 
}
 
51
void voronoicell_base::check_memory_for_copy(voronoicell_neighbor &vc,voronoicell_base* vb) {
 
52
        while(current_vertex_order<vb->current_vertex_order) add_memory_vorder(vc);
 
53
        for(int i=0;i<current_vertex_order;i++) while(mem[i]<vb->mec[i]) add_memory(vc,i,ds2);
 
54
        while(current_vertices<vb->p) add_memory_vertices(vc);
 
55
}
56
56
 
57
57
 
58
58
/** Copies the vertex and edge information from another class. The routine
377
377
 * \param[in] vc a reference to the specialized version of the calling class.
378
378
 * \param[in] lp the index of the point to add.
379
379
 * \param[in,out] stackp2 a pointer to the end of the stack entries. */
380
 
inline void voronoicell_base::add_to_stack(voronoicell_neighbor &vc,int lp,int *&stackp2) {
381
 
        (void)vc; /* Suppress "unused parameter" warning */
 
380
inline void voronoicell_base::add_to_stack(voronoicell_neighbor &vc,int lp,int *&stackp2) {
 
381
        (void)vc; /* Suppress "unused parameter" warning */
382
382
        for(int *k = (ds2);k<stackp2;k++) if(*k==lp) return;
383
383
        if(stackp2==stacke2) add_memory_ds2(stackp2);
384
384
        *(stackp2++)=lp;
391
391
 * \param[in] (x,y,z) the normal vector to the plane.
392
392
 * \param[in] rsq the distance along this vector of the plane.
393
393
 * \param[in] p_id the plane ID (for neighbor tracking only).
394
 
 * \return False if the plane cut deleted the cell entirely, true otherwise. */
 
394
 * \return False if the plane cut deleted the cell entirely, true otherwise. */
395
395
 
396
396
bool voronoicell_base::nplane(voronoicell_neighbor &vc,double x,double y,double z,double rsq,int p_id) {
397
397
        int count=0,i,j,k,lp=up,cp,qp,rp,*stackp = (ds),*stackp2 = (ds2),*dsp;
421
421
                                us++;
422
422
                        } while (us<nu[up]);
423
423
 
424
 
                        if(us==nu[up]) {
 
424
                        if(us==nu[up]) {
425
425
                                mprintf("\nB1.");
426
426
                                return false;
427
427
                        }
444
444
                                                us++;
445
445
                                        }
446
446
                                        if(us==nu[up]) {
447
 
                                                mprintf("\nB2.");
 
447
                                                mprintf("\nB2.");
448
448
                                                return false;
449
449
                                        }
450
450
                                }
504
504
                        complicated_setup=true;
505
505
                }
506
506
        }
507
 
        catch(bool except) {
508
 
                if (except)
 
507
        catch(bool except) {
 
508
                if (except)
509
509
                        except = 1;
510
510
                // This routine is a fall-back, in case floating point errors
511
511
                // cause the usual search routine to fail. In the fall-back
570
570
                                break;
571
571
                        }
572
572
                }
573
 
                if(qp==p) return qw==-1?true:false;
574
 
 
575
 
                if (qp==p)
576
 
                {
577
 
                        if (qw==-1)
578
 
                        {
579
 
                                return true;
580
 
                        } else
581
 
                        {
582
 
                                mprintf("\nB3.");
583
 
                                return false;
584
 
                        }
 
573
                if(qp==p) return qw==-1?true:false;
 
574
 
 
575
                if (qp==p)
 
576
                {
 
577
                        if (qw==-1)
 
578
                        {
 
579
                                return true;
 
580
                        } else
 
581
                        {
 
582
                                mprintf("\nB3.");
 
583
                                return false;
 
584
                        }
585
585
                }
586
586
        }
587
587
 
597
597
                // to find a vertex that has edges which are all inside or on
598
598
                // the plane. If the vertex has neighbors that are also on the
599
599
                // plane, we should check those too.
600
 
                if(!search_for_outside_edge(vc,up))
601
 
                {
602
 
                        mprintf("\nB4.");
603
 
                        return false;
 
600
                if(!search_for_outside_edge(vc,up))
 
601
                {
 
602
                        mprintf("\nB4.");
 
603
                        return false;
604
604
                }
605
605
 
606
606
                // The search algorithm found a point which is on the cutting
629
629
                                // then all of the vertices are inside
630
630
                                // or on the plane, so the cell is completely
631
631
                                // deleted
632
 
                                if(i==nu[up])
633
 
                                {
634
 
                                        mprintf("\nB5.");
635
 
                                        return false;
 
632
                                if(i==nu[up])
 
633
                                {
 
634
                                        mprintf("\nB5.");
 
635
                                        return false;
636
636
                                }
637
637
                                lp=ed[up][i];
638
638
                                lw=m_test(lp,l);