#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)
#//!\name Constructors
RboxPoints::
RboxPoints()
:PointCoordinates("rbox")
,rbox_new_count(0)
,rbox_status(qh_ERRnone)
,rbox_message()
{
allocateQhullQh();
}
//! Allocate and generate points according to rboxCommand
//! For rbox commands, see http://www.qhull.org/html/rbox.htm or html/rbox.htm
//! Same as appendPoints()
RboxPoints::
RboxPoints(constchar*rboxCommand)
:PointCoordinates("rbox")
,rbox_new_count(0)
,rbox_status(qh_ERRnone)
,rbox_message()
{
allocateQhullQh();
// rbox arguments added to comment() via qh_rboxpoints > qh_fprintf_rbox
appendPoints(rboxCommand);
}
RboxPoints::
~RboxPoints()
{
deleteqh();
resetQhullQh(0);
}
// RboxPoints and qh_rboxpoints has several fields in qhT (rbox_errexit..cpp_object)
// It shares last_random with qh_rand and qh_srand
// The other fields are unused
voidRboxPoints::
allocateQhullQh()
{
QHULL_LIB_CHECK/* Check for compatible library */
resetQhullQh(newQhullQh);
}//allocateQhullQh
#//!\name Messaging
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);
}
#//!\name Methods
//! Appends points as defined by rboxCommand
//! Appends rboxCommand to comment
//! For rbox commands, see http://www.qhull.org/html/rbox.htm or html/rbox.htm
voidRboxPoints::
appendPoints(constchar*rboxCommand)
{
strings("rbox ");
s+=rboxCommand;
char*command=const_cast<char*>(s.c_str());
if(qh()->cpp_object){
throwQhullError(10001,"Qhull error: conflicting user of cpp_object for RboxPoints::appendPoints() or corrupted qh_qh");
}
if(extraCoordinatesCount()!=0){
throwQhullError(10067,"Qhull error: Extra coordinates (%d) prior to calling RboxPoints::appendPoints. Was %s",extraCoordinatesCount(),0,0.0,comment().c_str());
}
countTpreviousCount=count();
qh()->cpp_object=this;// for qh_fprintf_rbox()
intstatus=qh_rboxpoints(qh(),command);
qh()->cpp_object=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());