QhullQh.cpp
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (c) 2008-2011 C.B. Barber. All rights reserved.
00004 ** $Id: //main/2011/qhull/src/libqhullcpp/QhullQh.cpp#2 $$Change: 1342 $
00005 ** $DateTime: 2011/03/07 21:55:47 $$Author: bbarber $
00006 **
00007 ****************************************************************************/
00008 
00009 #//! QhullQh -- Qhull's global data structure, qhT, as a C++ class
00010 
00011 
00012 
00013 #include "QhullError.h"
00014 #include "QhullQh.h"
00015 #include "QhullStat.h"
00016 
00017 #include <sstream>
00018 #include <iostream>
00019 
00020 using std::cerr;
00021 using std::string;
00022 using std::vector;
00023 using std::ostream;
00024 
00025 #ifdef _MSC_VER  // Microsoft Visual C++ -- warning level 4
00026 #pragma warning( disable : 4611)  // interaction between '_setjmp' and C++ object destruction is non-portable
00027 #pragma warning( disable : 4996)  // function was declared deprecated(strcpy, localtime, etc.)
00028 #endif
00029 
00030 namespace orgQhull {
00031 
00032 #//Global variables
00033 
00034 #//Constructor, destructor, etc.
00035 
00039 QhullQh::
00040 QhullQh()
00041 {
00042     static boolT firstcall = True;
00043 
00044     if(firstcall){
00045         if(qhmem.BUFinit!=0){
00046             throw QhullError(10017, "Qhull error: qhmem already initialized by another class.");
00047         }
00048         qh_meminit(NULL);
00049         firstcall= False;
00050     }
00051     // QhullQh() and UsingLibQhull() are the same
00052 #if qh_QHpointer
00053     if(qh_qh){
00054         if(qh old_qhstat){
00055             throw QhullError(10041, "Qhull internal error: qh_qh.old_qhstat defined (%x) but qh_qh is active.  qh_qh not restored correctly.", 0, 0, 0.0, qh old_qhstat);
00056         }
00057         qh old_qhstat= qh_qhstat;
00058         qh old_tempstack= qhmem.tempstack;
00059         qh_qhstat= 0;
00060         qhmem.tempstack= 0;
00061     }
00062     qh_qh= static_cast<qhT*>(this);
00063 #else
00064     if(strncmp(qh qhull, "qhull", 5) == 0){
00065         throw QhullError(10022, "Qhull error: Qhull already initialized as run %d", qh run_id);
00066     }
00067 #endif
00068     // NOerrors -- Does not call qh_errexit()
00069     qh_initstatistics();
00070     // NOerrors -- Does not call qh_errexit()
00071     qh_initqhull_start2(NULL, NULL, qh_FILEstderr);
00072 }//QhullQh
00073 
00075 QhullQh::
00076 ~QhullQh()
00077 {
00078 #if qh_QHpointer
00079     if(!qh_qh){
00080         QhullError e(10042, "Qhull internal error: qh_qh undefined.  Was ~QhullQh() invoked independent of UsingLibQhull?", qh run_id, 0, 0, qh_qh);
00081         e.logError();
00082     }else if(!qh_qhstat){
00083         QhullError e(10043, "Qhull internal error: qh_qhstat null.  Is another thread running?");
00084         e.logError();
00085     }else if(qh_qh!=this){
00086         QhullError e(10044, "Qhull error: ~QhullQh() invoked independent of UsingLibQhull. qh_qh %x (runId %d) vs. QhullQh.runId %d.", qh run_id, run_id, 0.0, qh_qh);
00087         e.logError();
00088     }else{
00089         qh_freeqhull2(qh_ALL); // sets qh.NOerrexit.  Clears struct *qh_qh including run_id, but not qh_qh itself
00090     }
00091 #else
00092     if(&qh_qh!=this){
00093         QhullError e(10045, "Qhull error: ~QhullQh() invoked independent of UsingLibQhull. qh_qh %x (runId %d) vs. QhullQh.runId %d.", qh run_id, run_id, 0.0, qh_qh);
00094         e.logError();
00095     }else{
00096         qh_freeqhull2(qh_ALL); // sets qh.NOerrexit.  Clears struct *qh_qh including run_id, but not qh_qh itself
00097     }
00098 #endif
00099 }//~QhullQh
00100 
00101 #//Parallel Access
00102 
00103 }//namespace orgQhull
00104 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


libqhull
Author(s): Robert Krug
autogenerated on Tue Jun 18 2013 12:38:50