#ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
#pragma warning( disable : 4996) // function was declared deprecated(strcpy, localtime, etc.)
#endif
namespaceorgQhull{
#//! 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(constchar*rboxCommand)
:PointCoordinates("rbox")
,rbox_new_count(0)
,rbox_status(qh_ERRnone)
,rbox_message()
{
appendPoints(rboxCommand);
}
RboxPoints::
RboxPoints(constRboxPoints&other)
:PointCoordinates(other)
,rbox_new_count(0)
,rbox_status(other.rbox_status)
,rbox_message(other.rbox_message)
{}
RboxPoints&RboxPoints::
operator=(constRboxPoints&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
voidRboxPoints::
clearRboxMessage()
{
rbox_status=qh_ERRnone;
rbox_message.clear();
}//clearRboxMessage
std::stringRboxPoints::
rboxMessage()const
{
if(rbox_status!=qh_ERRnone){
returnrbox_message;
}
if(isEmpty()){
return"rbox warning: no points generated\n";
}
return"rbox: OK\n";
}//rboxMessage
intRboxPoints::
rboxStatus()const
{
returnrbox_status;
}
boolRboxPoints::
hasRboxMessage()const
{
return(rbox_status!=qh_ERRnone);
}
#//Modify
voidRboxPoints::
appendPoints(constchar*rboxCommand)
{
strings("rbox ");
s+=rboxCommand;
char*command=const_cast<char*>(s.c_str());
if(rbox_output){
throwQhullError(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){
throwQhullError(10067,"Qhull error: Extra coordinates (%d) prior to calling RboxPoints::appendPoints. Was %s",extraCoordinatesCount(),0,0.0,comment().c_str());
}
intpreviousCount=count();
rbox_output=this;// set rbox_output for qh_fprintf()
intstatus=::qh_rboxpoints(0,0,command);
rbox_output=0;
if(rbox_status==qh_ERRnone){
rbox_status=status;
}
if(rbox_status!=qh_ERRnone){
throwQhullError(rbox_status,rbox_message);
}
if(extraCoordinatesCount()!=0){
throwQhullError(10002,"Qhull error: extra coordinates (%d) for PointCoordinates (%x)",extraCoordinatesCount(),0,0.0,coordinates());
}
if(previousCount+newCount()!=count()){
throwQhullError(10068,"Qhull error: rbox specified %d points but got %d points for command '%s'",newCount(),count()-previousCount,0.0,comment().c_str());