[10207] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (c) 2008-2012 C.B. Barber. All rights reserved.
|
---|
| 4 | ** $Id: //main/2011/qhull/src/libqhullcpp/QhullRidge.cpp#4 $$Change: 1464 $
|
---|
| 5 | ** $DateTime: 2012/01/25 22:58:41 $$Author: bbarber $
|
---|
| 6 | **
|
---|
| 7 | ****************************************************************************/
|
---|
| 8 |
|
---|
| 9 | #//! QhullRidge -- Qhull's ridge structure, ridgeT, as a C++ class
|
---|
| 10 |
|
---|
| 11 | #include "QhullSets.h"
|
---|
| 12 | #include "QhullVertex.h"
|
---|
| 13 | #include "QhullRidge.h"
|
---|
| 14 |
|
---|
| 15 | #ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
|
---|
| 16 | #pragma warning( disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
|
---|
| 17 | #pragma warning( disable : 4996) // function was declared deprecated(strcpy, localtime, etc.)
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
| 20 | namespace orgQhull {
|
---|
| 21 |
|
---|
| 22 | #//class statics
|
---|
| 23 | ridgeT QhullRidge::
|
---|
| 24 | s_empty_ridge= {0,0,0,0,0,
|
---|
| 25 | 0,0};
|
---|
| 26 |
|
---|
| 27 | #//Constructor, destructor, etc.
|
---|
| 28 |
|
---|
| 29 | #//Accessors
|
---|
| 30 |
|
---|
| 31 | //! Return True if nextRidge3d
|
---|
| 32 | //! Simplicial facets may have incomplete ridgeSets
|
---|
| 33 | //! Does not use qh_qh or qh_errexit()
|
---|
| 34 | bool QhullRidge::
|
---|
| 35 | hasNextRidge3d(const QhullFacet f) const
|
---|
| 36 | {
|
---|
| 37 | vertexT *v= 0;
|
---|
| 38 | ridgeT *ridge= qh_nextridge3d(getRidgeT(), f.getFacetT(), &v);
|
---|
| 39 | return (ridge!=0);
|
---|
| 40 | }//hasNextRidge3d
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | //! Return next ridge and optional vertex for a 3d facet and ridge
|
---|
| 45 | //! Does not use qh_qh or qh_errexit()
|
---|
| 46 | QhullRidge QhullRidge::
|
---|
| 47 | nextRidge3d(const QhullFacet f, QhullVertex *nextVertex) const
|
---|
| 48 | {
|
---|
| 49 | vertexT *v= 0;
|
---|
| 50 | ridgeT *ridge= qh_nextridge3d(getRidgeT(), f.getFacetT(), &v);
|
---|
| 51 | if(!ridge){
|
---|
| 52 | throw QhullError(10030, "Qhull error nextRidge3d: missing next ridge for facet %d ridge %d. Does facet contain ridge?", f.id(), id());
|
---|
| 53 | }
|
---|
| 54 | if(nextVertex!=0){
|
---|
| 55 | *nextVertex= QhullVertex(v);
|
---|
| 56 | }
|
---|
| 57 | return QhullRidge(ridge);
|
---|
| 58 | }//nextRidge3d
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | }//namespace orgQhull
|
---|
| 62 |
|
---|
| 63 | #//Global functions
|
---|
| 64 |
|
---|
| 65 | using std::endl;
|
---|
| 66 | using std::ostream;
|
---|
| 67 | using orgQhull::QhullRidge;
|
---|
| 68 | using orgQhull::QhullVertex;
|
---|
| 69 | using orgQhull::UsingLibQhull;
|
---|
| 70 |
|
---|
| 71 | ostream &
|
---|
| 72 | operator<<(ostream &os, const QhullRidge &r)
|
---|
| 73 | {
|
---|
| 74 | os << r.print(UsingLibQhull::NOqhRunId);
|
---|
| 75 | return os;
|
---|
| 76 | }//<< QhullRidge
|
---|
| 77 |
|
---|
| 78 | //! Duplicate of qh_printridge [io.c]
|
---|
| 79 | //! if pr.run_id==UsingLibQhull::NOqhRunId, no access to qh [needed for QhullVertex/QhullPoint]
|
---|
| 80 | ostream &
|
---|
| 81 | operator<<(ostream &os, const QhullRidge::PrintRidge &pr)
|
---|
| 82 | {
|
---|
| 83 | QhullRidge r= *pr.ridge;
|
---|
| 84 | os << " - r" << r.id();
|
---|
| 85 | if(r.getRidgeT()->tested){
|
---|
| 86 | os << " tested";
|
---|
| 87 | }
|
---|
| 88 | if(r.getRidgeT()->nonconvex){
|
---|
| 89 | os << " nonconvex";
|
---|
| 90 | }
|
---|
| 91 | os << endl;
|
---|
| 92 | os << r.vertices().print(pr.run_id, " vertices:");
|
---|
| 93 | if(r.getRidgeT()->top && r.getRidgeT()->bottom){
|
---|
| 94 | os << " between f" << r.topFacet().id() << " and f" << r.bottomFacet().id() << endl;
|
---|
| 95 | }else if(r.getRidgeT()->top){
|
---|
| 96 | os << " top f" << r.topFacet().id() << endl;
|
---|
| 97 | }else if(r.getRidgeT()->bottom){
|
---|
| 98 | os << " bottom f" << r.bottomFacet().id() << endl;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | return os;
|
---|
| 102 | }//<< PrintRidge
|
---|