#ifndef __MAILABLE_H #define __MAILABLE_H #include "AxisAlignedBox3.h" #include "Pvs.h" #include #include "VssRay.h" namespace GtpVisibilityPreprocessor { #define MAX_THREADS 2 class Mailable { public: enum {STD_MAILABLE=0, INTERSECTABLE }; // last mail id -> warning not thread safe! // both mailId and mailbox should be unique for each thread!!! static int ssMailId[MAX_THREADS]; /// Mailbox used for traversals int mMailbox[MAX_THREADS]; // Get mailable Id has to be reimplemented for all objects which aim to // have independent mailing virtual int GetMailableId() { return STD_MAILABLE; } //////////////////////////////////////////////// // Mailing stuff Mailable() { for (int i=0; i < MAX_THREADS; i++) mMailbox[i] = 0; } static int GetThreadId(); static void NewMail(const int reserve = 1) { int id = GetThreadId(); ssMailId[id] += reserve; } void Mail() { int id = GetThreadId(); Mail(id); } void Mail(const int threadId) { mMailbox[threadId] = ssMailId[threadId]; } bool Mailed() const { int id = GetThreadId(); return Mailed(id); } bool Mailed(const int threadId) const { return mMailbox[threadId] == ssMailId[threadId]; } void MailSpecial(const int threadId, const int mailbox) { mMailbox[threadId] = ssMailId[threadId] + mailbox; } bool MailedSpecial(const int threadId, const int mailbox) const { return mMailbox[threadId] == ssMailId[threadId] + mailbox; } int IncMail(const int threadId) { return ++ mMailbox[threadId] - ssMailId[threadId]; } }; } #endif