本文整理汇总了C++中Severe函数的典型用法代码示例。如果您正苦于以下问题:C++ Severe函数的具体用法?C++ Severe怎么用?C++ Severe使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Severe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Severe
ConditionVariable::ConditionVariable() {
int err;
if ((err = pthread_cond_init(&cond, NULL)) != 0)
Severe("Error from pthread_cond_init: %s", strerror(err));
if ((err = pthread_mutex_init(&mutex, NULL)) != 0)
Severe("Error from pthread_mutex_init: %s", strerror(err));
}
示例2: Assert
void RWMutexLock::UpgradeToWrite() {
Assert(type == READ);
int err;
if ((err = pthread_rwlock_unlock(&mutex.mutex)) != 0)
Severe("Error from pthread_rwlock_unlock: %s", strerror(err));
if ((err = pthread_rwlock_wrlock(&mutex.mutex)) != 0)
Severe("Error from pthread_rwlock_wrlock: %s", strerror(err));
type = WRITE;
}
示例3: sem_destroy
Semaphore::~Semaphore() {
#ifdef __OpenBSD__
int err = sem_destroy(sem);
free((void *)sem);
sem = NULL;
if (err != 0)
Severe("Error from sem_destroy: %s", strerror(err));
#else
int err;
if ((err = sem_close(sem)) != 0)
Severe("Error from sem_close: %s", strerror(err));
#endif // !__OpenBSD__
}
示例4: Severe
void Scene::Intersect(const RayDifferential* ray, Intersection *isect, bool* hit,
const int & count, const unsigned int & samplesPerPixel
#ifdef STAT_RAY_TRIANGLE
, Spectrum *Ls
#endif
) const {
RayHieararchy* rh = dynamic_cast<RayHieararchy*>(aggregate);
if ( rh != NULL){
rh->Intersect(ray, isect, hit, count
#ifdef STAT_RAY_TRIANGLE
,Ls
#endif
);
return;
}
RayBVH* rbvh = dynamic_cast<RayBVH*>(aggregate);
if ( rbvh != NULL){
rbvh->Intersect(ray, isect, hit, count
#ifdef STAT_RAY_TRIANGLE
,Ls
#endif
);
return;
}
NaiveAccel* na = dynamic_cast<NaiveAccel*>(aggregate);
if ( na != NULL)
na->Intersect(ray, isect, hit, count);
else
Severe("Called Intersect with unsupported aggregate!");
}
示例5: InitializeCriticalSection
RWMutex::RWMutex() {
numWritersWaiting = numReadersWaiting = activeWriterReaders = 0;
InitializeCriticalSection(&cs);
hReadyToRead = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hReadyToRead == NULL) {
Severe("Error creating event for RWMutex: %d", GetLastError());
}
hReadyToWrite = CreateSemaphore(NULL, 0, 1, NULL);
if (hReadyToWrite == NULL) {
DWORD lastError = GetLastError();
CloseHandle(hReadyToRead);
Severe("Error creating semaphore for RWMutex: %d", lastError);
}
}
示例6: TasksCleanup
void TasksCleanup() {
#ifdef PBRT_USE_GRAND_CENTRAL_DISPATCH
return;
#else // // PBRT_USE_GRAND_CENTRAL_DISPATCH
{ MutexLock lock(*taskQueueMutex);
Assert(taskQueue.size() == 0);
}
static const int nThreads = NumSystemCores();
workerSemaphore.Post(nThreads);
if (threads != NULL) {
#ifdef PBRT_HAS_PTHREADS
for (int i = 0; i < nThreads; ++i) {
int err = pthread_join(threads[i], NULL);
if (err != 0)
Severe("Error from pthread_join: %s", strerror(err));
}
#endif
#ifdef WIN32
WaitForMultipleObjects(nThreads, threads, TRUE, INFINITE);
for (int i = 0; i < nThreads; ++i) {
CloseHandle(threads[i]);
}
#endif // WIN32
delete[] threads;
threads = NULL;
}
#endif // PBRT_USE_GRAND_CENTRAL_DISPATCH
}
示例7: Severe
void Aggregate::ComputeScatteringFunctions(SurfaceInteraction *isect,
MemoryArena &arena,
TransportMode mode,
bool allowMultipleLobes) const {
Severe(
"Aggregate::ComputeScatteringFunctions() method"
"called; should have gone to GeometricPrimitive");
}
示例8: defined
// Timer Method Definitions
Timer::Timer()
{
#if defined( IRIX ) || defined( IRIX64 )
// IRIX Timer Initialization
__psunsigned_t phys_addr, raddr;
int poffmask = getpagesize() - 1;
int counterSize = syssgi(SGI_CYCLECNTR_SIZE);
phys_addr = syssgi(SGI_QUERY_CYCLECNTR, &(cycleval));
if (phys_addr == ENODEV) {
Severe( "Sorry, this SGI doesn't support timers." );
}
raddr = phys_addr & ~poffmask;
fd = open("/dev/mmem", O_RDONLY);
if (counterSize == 64) {
iotimer_addr64 =
(volatile iotimer64_t *)mmap(0, poffmask, PROT_READ,
MAP_PRIVATE, fd, (off_t)raddr);
unmapLocation = (void *)iotimer_addr64;
unmapSize = poffmask;
iotimer_addr64 = (iotimer64_t *)((__psunsigned_t)iotimer_addr64 +
(phys_addr & poffmask));
}
else if (counterSize == 32) {
iotimer_addr32 = (volatile iotimer32_t *)mmap(0, poffmask, PROT_READ,
MAP_PRIVATE, fd,
(off_t)raddr);
unmapLocation = (void *)iotimer_addr32;
unmapSize = poffmask;
iotimer_addr32 = (iotimer32_t *)((__psunsigned_t)iotimer_addr32 +
(phys_addr & poffmask));
}
else {
Severe( "Fatal timer init error" );
}
#elif defined( WIN32 )
// Windows Timer Initialization
QueryPerformanceFrequency( &performance_frequency );
one_over_frequency = 1.0/((double)performance_frequency.QuadPart);
#endif
time0 = elapsed = 0;
running = 0;
}
示例9: memset
AsymptoticNewmark::AsymptoticNewmark(Scalar beta, Scalar gamma, int DOFS, Scalar massDamp, Scalar stiffDamp, Scalar ts,
const Reference<Mesh>& m, const Reference<NodeIndexer>& nodeIndexer, ReducedHyperelasticMaterial* mater)
:Intergrator(DOFS, massDamp, stiffDamp, ts){
int orderCount = mater->getNonlinearAsymptoticOrder();
int entrys = orderCount*dofs;
d = allocAligned<Scalar>(entrys);
v = allocAligned<Scalar>(entrys);
a = allocAligned<Scalar>(entrys);
pre_d = allocAligned<Scalar>(entrys);
pre_v = allocAligned<Scalar>(entrys);
pre_a = allocAligned<Scalar>(entrys);
externalVirtualWork = allocAligned<Scalar>(entrys);
memset(d, 0, entrys*sizeof(Scalar));
memset(v, 0, entrys*sizeof(Scalar));
memset(a, 0, entrys*sizeof(Scalar));
memset(pre_d, 0, entrys*sizeof(Scalar));
memset(pre_v, 0, entrys*sizeof(Scalar));
memset(pre_a, 0, entrys*sizeof(Scalar));
memset(externalVirtualWork, 0, entrys*sizeof(Scalar));
mesh = m;
indexer = nodeIndexer;
material = mater;
betaDeltaT2 = beta*timeStep*timeStep;
gammaDeltaT = gamma*timeStep;
minusBetaDeltaT2 = timeStep*timeStep*Scalar(0.5) - betaDeltaT2;
minusGammaDeltaT = timeStep - gammaDeltaT;
totalDofs = indexer->getMatrixOrder(mesh);
frequencies2 = allocAligned<Scalar>(dofs);
basises = allocAligned<Scalar>(dofs*totalDofs);
SparseMatrixAssembler M(totalDofs);
SparseMatrixAssembler K(totalDofs);
material->generateMassMatrix(mesh, indexer, M);
material->generateStiffnessMatrix(mesh, indexer, K);
EigenSolver slover;
slover.getEigenValVectors(dofs, M, K, frequencies2, basises);
material->preprocessWithReduction(mesh, indexer);
loadFactors = allocAligned<Scalar>(orderCount);
fullDisplacements = allocAligned<Scalar>(orderCount*totalDofs);
vwBuffer = allocAligned<Scalar>(totalDofs);
#ifdef ODER_DEBUG
for (int i = 0; i < dofs; i++){
if (frequencies2[i] < 0.0)
Severe("Stiffness Matrix is not semi-define");
}
#endif
}
示例10: TasksInit
void TasksInit() {
#ifdef PBRT_USE_GRAND_CENTRAL_DISPATCH
return;
#else // PBRT_USE_GRAND_CENTRAL_DISPATCH
static const int nThreads = NumSystemCores();
#ifdef PBRT_HAS_PTHREADS
threads = new pthread_t[nThreads];
for (int i = 0; i < nThreads; ++i) {
int err = pthread_create(&threads[i], NULL, &taskEntry, reinterpret_cast<void *>(i));
if (err != 0)
Severe("Error from pthread_create: %s", strerror(err));
}
#endif // !PBRT_HAS_PTHREADS
#ifdef WIN32
threads = new HANDLE[nThreads];
for (int i = 0; i < nThreads; ++i) {
threads[i] = CreateThread(NULL, 0, taskEntry, reinterpret_cast<void *>(i), 0, NULL);
if (threads[i] == NULL)
Severe("Error from CreateThread");
}
#endif // WIN32
#endif // PBRT_USE_GRAND_CENTRAL_DISPATCH
}
示例11: InterpolateSpectrumSamples
float InterpolateSpectrumSamples(const float *lambda, const float *vals,
int n, float l) {
for (int i = 0; i < n-1; ++i) Assert(lambda[i+1] > lambda[i]);
if (l <= lambda[0]) return vals[0];
if (l >= lambda[n-1]) return vals[n-1];
for (int i = 0; i < n-1; ++i) {
if (l >= lambda[i] && l <= lambda[i+1]) {
float t = (l - lambda[i]) / (lambda[i+1] - lambda[i]);
return Lerp(t, vals[i], vals[i+1]);
}
}
Severe("Fatal logic error in InterpolateSpectrumSamples()");
return 0.f;
}
示例12: XmlParseConfig
bool XmlParseConfig(Config &c, TiXmlElement *conf)
{
if ( conf == NULL ) return false;
stringstream ss;
TiXmlElement *config = conf->FirstChildElement();
for ( ; config; config = config->NextSiblingElement() ) {
if ( config->Type() != TiXmlNode::TINYXML_ELEMENT ) continue;
string configType(config->Value());
const char *name = config->Attribute("Name");
if ( !name ) {
Severe("Config Name attribute missing");
return false;
}
string configName(name);
if ( configType == "Float" ) {
double value;
if ( !config->Attribute("Value", &value) ) {
ss << "Config [" << configName << "] missing value";
Severe(ss);
return false;
}
c.AddAttribute(configName, (float) value);
} else if ( configType == "Int32" ) {
int i;
if ( !config->Attribute("Value", &i) ) {
ss << "Config [" << configName << "] missing value";
Severe(ss);
return false;
}
c.AddAttribute(configName, i);
} else if ( configType == "Vector" ) {
Vector vec;
TiXmlElement *elemVec = config->FirstChildElement("Value");
if ( !elemVec ) {
ss << "Config [" << configName << "] missing value";
Severe(ss);
return false;
}
if ( !XmlParseVector(vec, elemVec) ) return false;
c.AddAttribute(configName, vec);
} else if ( configType == "Bool" ) {
int b;
if ( !config->Attribute("Value", &b) ) {
ss << "Config [" << configName << "] missing value";
Severe(ss);
return false;
}
c.AddAttribute(configName, b != 0);
} else {
ss << "Unknown config type: [" << configType << "]";
Severe(ss);
return false;
}
}
return true;
}
示例13: rScene
void RealisticCamera::ComputeThickLensApproximation(Float pz[2],
Float fz[2]) const {
// Find height $x$ from optical axis for parallel rays
Float x = .001 * film->diagonal;
// Compute cardinal points for film side of lens system
Ray rScene(Point3f(x, 0, LensFrontZ() + 1), Vector3f(0, 0, -1));
Ray rFilm;
bool ok = TraceLensesFromScene(rScene, &rFilm);
if (!ok)
Severe(
"Unable to trace ray from scene to film for thick lens "
"approximation. Is aperture stop extremely small?");
ComputeCardinalPoints(rScene, rFilm, &pz[0], &fz[0]);
// Compute cardinal points for scene side of lens system
rFilm = Ray(Point3f(x, 0, LensRearZ() - 1), Vector3f(0, 0, 1));
ok = TraceLensesFromFilm(rFilm, &rScene);
if (!ok)
Severe(
"Unable to trace ray from film to scene for thick lens "
"approximation. Is aperture stop extremely small?");
ComputeCardinalPoints(rFilm, rScene, &pz[1], &fz[1]);
}
示例14: XmlParseColor
bool XmlParseColor(Color &c, TiXmlElement *color)
{
if ( color == NULL ) return false;
double r, g, b;
const char *pAttrR = color->Attribute("R", &r);
const char *pAttrG = color->Attribute("G", &g);
const char *pAttrB = color->Attribute("B", &b);
if ( !pAttrR || !pAttrG || !pAttrB ) {
Severe("Invalid color value");
return false;
}
c.x = (float) r;
c.y = (float) g;
c.z = (float) b;
return true;
}
示例15: convert
static Float convert(void *p, int offset, int type) {
switch (type) {
case TINYEXR_PIXELTYPE_UINT: {
int32_t *pix = (int32_t *)p;
return pix[offset];
}
case TINYEXR_PIXELTYPE_HALF:
case TINYEXR_PIXELTYPE_FLOAT: {
float *pix = (float *)p;
return pix[offset];
}
default:
Severe("Unexpected pixel type in EXR image");
return 0;
}
}