#ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
#pragma warning( disable : 4996) // function was declared deprecated(strcpy, localtime, etc.)
#endif
namespace orgQhull {
#//! RboxPoints -- generate random PointCoordinates for qhull (rbox)
#//Global
//! pointer to RboxPoints for qh_fprintf callback
RboxPoints *rbox_output= 0;
#//Construct
RboxPoints::
RboxPoints()
: PointCoordinates("rbox")
, rbox_new_count(0)
, rbox_status(qh_ERRnone)
, rbox_message()
{}
RboxPoints::
RboxPoints(const char *rboxCommand)
: PointCoordinates("rbox ")
, rbox_new_count(0)
, rbox_status(qh_ERRnone)
, rbox_message()
{
std::string s= comment() + rboxCommand;
setComment(s);
appendPoints(rboxCommand);
}
RboxPoints::
RboxPoints(const RboxPoints &other)
: PointCoordinates(other)
, rbox_new_count(0)
, rbox_status(other.rbox_status)
, rbox_message(other.rbox_message)
{}
RboxPoints & RboxPoints::
operator=(const RboxPoints &other)
{
PointCoordinates::operator=(other);
rbox_new_count= other.rbox_new_count;
rbox_status= other.rbox_status;
rbox_message= other.rbox_message;
return *this;
}//operator=
RboxPoints::
~RboxPoints()
{}
#//Error
void RboxPoints::
clearRboxMessage()
{
rbox_status= qh_ERRnone;
rbox_message.clear();
}//clearRboxMessage
std::string RboxPoints::
rboxMessage() const
{
if(rbox_status!=qh_ERRnone){
return rbox_message;
}
if(isEmpty()){
return "rbox warning: no points generated\n";
}
return "rbox: OK\n";
}//rboxMessage
int RboxPoints::
rboxStatus() const
{
return rbox_status;
}
bool RboxPoints::
hasRboxMessage() const
{
return (rbox_status!=qh_ERRnone);
}
#//Modify
void RboxPoints::
appendPoints(const char *rboxCommand)
{
string s("rbox ");
s += rboxCommand;
char *command= const_cast<char*>(s.c_str());
if(rbox_output){
throw QhullError(10001, "Qhull error: Two simultaneous calls to RboxPoints::appendPoints(). Prevent two processes calling appendPoints() at the same time. Other RboxPoints '%s'", 0, 0, 0, rbox_output->comment().c_str());
}
if(extraCoordinatesCount()!=0){
throw QhullError(10067, "Qhull error: Extra coordinates (%d) prior to calling RboxPoints::appendPoints. Was %s", extraCoordinatesCount(), 0, 0.0, comment().c_str());
}
int previousCount= count();
rbox_output= this; // set rbox_output for qh_fprintf()
int status= ::qh_rboxpoints(0, 0, command);
rbox_output= 0;
if(rbox_status==qh_ERRnone){
rbox_status= status;
}
if(rbox_status!=qh_ERRnone){
throw QhullError(rbox_status, rbox_message);
}
if(extraCoordinatesCount()!=0){
throw QhullError(10002, "Qhull error: extra coordinates (%d) for PointCoordinates (%x)", extraCoordinatesCount(), 0, 0.0, coordinates());
}
if(previousCount+newCount()!=count()){
throw QhullError(10068, "Qhull error: rbox specified %d points but got %d points for command '%s'", newCount(), count()-previousCount, 0.0, comment().c_str());