mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-23 08:20:06 +00:00
Merge pull request #719 from barfowl/far_errors
Minor content and formatting changes to Far error strings
This commit is contained in:
commit
c8943d12b3
@ -33,38 +33,44 @@ namespace OPENSUBDIV_VERSION {
|
|||||||
|
|
||||||
namespace Far {
|
namespace Far {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Statics for the publicly assignable callbacks and the methods to
|
||||||
|
// assign them (disable static assignment warnings when doing so):
|
||||||
|
//
|
||||||
static ErrorCallbackFunc errorFunc = 0;
|
static ErrorCallbackFunc errorFunc = 0;
|
||||||
|
static WarningCallbackFunc warningFunc = 0;
|
||||||
static char const * errors[] = {
|
|
||||||
"FAR_NO_ERROR",
|
|
||||||
"FAR_FATAL_ERROR",
|
|
||||||
"FAR_INTERNAL_CODING_ERROR",
|
|
||||||
"FAR_CODING_ERROR",
|
|
||||||
"FAR_RUNTIME_ERROR"
|
|
||||||
};
|
|
||||||
|
|
||||||
void SetErrorCallback(ErrorCallbackFunc func) {
|
|
||||||
|
|
||||||
#ifdef __INTEL_COMPILER
|
#ifdef __INTEL_COMPILER
|
||||||
#pragma warning disable 1711
|
#pragma warning disable 1711
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void SetErrorCallback(ErrorCallbackFunc func) {
|
||||||
errorFunc = func;
|
errorFunc = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetWarningCallback(WarningCallbackFunc func) {
|
||||||
|
warningFunc = func;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __INTEL_COMPILER
|
#ifdef __INTEL_COMPILER
|
||||||
#pragma warning enable 1711
|
#pragma warning enable 1711
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
void Error(ErrorType err) {
|
|
||||||
|
|
||||||
if (errorFunc) {
|
|
||||||
errorFunc(err, NULL);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Error : %s\n",errors[err]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// The default error and warning callbacks eventually belong in the
|
||||||
|
// internal namespace:
|
||||||
|
//
|
||||||
void Error(ErrorType err, const char *format, ...) {
|
void Error(ErrorType err, const char *format, ...) {
|
||||||
|
|
||||||
|
static char const * errorTypeLabel[] = {
|
||||||
|
"No Error",
|
||||||
|
"Fatal Error",
|
||||||
|
"Coding Error (internal)",
|
||||||
|
"Coding Error",
|
||||||
|
"Error"
|
||||||
|
};
|
||||||
|
|
||||||
assert(err!=FAR_NO_ERROR);
|
assert(err!=FAR_NO_ERROR);
|
||||||
|
|
||||||
char message[10240];
|
char message[10240];
|
||||||
@ -76,23 +82,10 @@ void Error(ErrorType err, const char *format, ...) {
|
|||||||
if (errorFunc) {
|
if (errorFunc) {
|
||||||
errorFunc(err, message);
|
errorFunc(err, message);
|
||||||
} else {
|
} else {
|
||||||
printf("Error %s : %s\n",errors[err], message);
|
printf("%s: %s\n", errorTypeLabel[err], message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static WarningCallbackFunc warningFunc = 0;
|
|
||||||
|
|
||||||
void SetWarningCallback(WarningCallbackFunc func) {
|
|
||||||
|
|
||||||
#ifdef __INTEL_COMPILER
|
|
||||||
#pragma warning disable 1711
|
|
||||||
#endif
|
|
||||||
warningFunc = func;
|
|
||||||
#ifdef __INTEL_COMPILER
|
|
||||||
#pragma warning enable 1711
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Warning(const char *format, ...) {
|
void Warning(const char *format, ...) {
|
||||||
|
|
||||||
char message[10240];
|
char message[10240];
|
||||||
@ -104,7 +97,7 @@ void Warning(const char *format, ...) {
|
|||||||
if (warningFunc) {
|
if (warningFunc) {
|
||||||
warningFunc(message);
|
warningFunc(message);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stdout, "Warning : %s\n", message);
|
fprintf(stdout, "Warning: %s\n", message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ typedef enum {
|
|||||||
FAR_RUNTIME_ERROR ///< Issue a generic runtime error, but continue execution.
|
FAR_RUNTIME_ERROR ///< Issue a generic runtime error, but continue execution.
|
||||||
} ErrorType;
|
} ErrorType;
|
||||||
|
|
||||||
|
|
||||||
|
/// \brief The error callback function type (default is "printf")
|
||||||
typedef void (*ErrorCallbackFunc)(ErrorType err, const char *message);
|
typedef void (*ErrorCallbackFunc)(ErrorType err, const char *message);
|
||||||
|
|
||||||
/// \brief Sets the error callback function (default is "printf")
|
/// \brief Sets the error callback function (default is "printf")
|
||||||
@ -50,22 +52,8 @@ typedef void (*ErrorCallbackFunc)(ErrorType err, const char *message);
|
|||||||
///
|
///
|
||||||
void SetErrorCallback(ErrorCallbackFunc func);
|
void SetErrorCallback(ErrorCallbackFunc func);
|
||||||
|
|
||||||
/// \brief Sends an OSD error
|
|
||||||
///
|
|
||||||
/// @param err the error type
|
|
||||||
///
|
|
||||||
void Error(ErrorType err);
|
|
||||||
|
|
||||||
/// \brief Sends an OSD error with a message
|
/// \brief The warning callback function type (default is "printf")
|
||||||
///
|
|
||||||
/// @param err the error type
|
|
||||||
///
|
|
||||||
/// @param format the format of the message (followed by arguments)
|
|
||||||
///
|
|
||||||
void Error(ErrorType err, const char *format, ...);
|
|
||||||
|
|
||||||
|
|
||||||
/// \brief Sets the warning callback function (default is "printf")
|
|
||||||
typedef void (*WarningCallbackFunc)(const char *message);
|
typedef void (*WarningCallbackFunc)(const char *message);
|
||||||
|
|
||||||
/// \brief Sets the warning callback function (default is "printf")
|
/// \brief Sets the warning callback function (default is "printf")
|
||||||
@ -76,7 +64,21 @@ typedef void (*WarningCallbackFunc)(const char *message);
|
|||||||
///
|
///
|
||||||
void SetWarningCallback(WarningCallbackFunc func);
|
void SetWarningCallback(WarningCallbackFunc func);
|
||||||
|
|
||||||
/// \brief Sends an OSD warning message
|
|
||||||
|
//
|
||||||
|
// The following are intended for internal use only (and will eventually
|
||||||
|
// be moved within namespace internal)
|
||||||
|
//
|
||||||
|
|
||||||
|
/// \brief Sends an OSD error with a message (internal use only)
|
||||||
|
///
|
||||||
|
/// @param err the error type
|
||||||
|
///
|
||||||
|
/// @param format the format of the message (followed by arguments)
|
||||||
|
///
|
||||||
|
void Error(ErrorType err, const char *format, ...);
|
||||||
|
|
||||||
|
/// \brief Sends an OSD warning message (internal use only)
|
||||||
///
|
///
|
||||||
/// @param format the format of the message (followed by arguments)
|
/// @param format the format of the message (followed by arguments)
|
||||||
///
|
///
|
||||||
|
@ -317,7 +317,8 @@ PrimvarRefiner::Limit(T const & src, U & dst) const {
|
|||||||
|
|
||||||
if (_refiner.getLevel(_refiner.GetMaxLevel()).getNumVertexEdgesTotal() == 0) {
|
if (_refiner.getLevel(_refiner.GetMaxLevel()).getNumVertexEdgesTotal() == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR,
|
||||||
"Cannot compute limit points -- last level of refinement does not include full topology.");
|
"Failure in PrimvarRefiner::Limit() -- "
|
||||||
|
"last level of refinement does not include full topology.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +341,8 @@ PrimvarRefiner::Limit(T const & src, U & dstPos, U1 & dstTan1, U2 & dstTan2) con
|
|||||||
|
|
||||||
if (_refiner.getLevel(_refiner.GetMaxLevel()).getNumVertexEdgesTotal() == 0) {
|
if (_refiner.getLevel(_refiner.GetMaxLevel()).getNumVertexEdgesTotal() == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR,
|
||||||
"Cannot compute limit points -- last level of refinement does not include full topology.");
|
"Failure in PrimvarRefiner::Limit() -- "
|
||||||
|
"last level of refinement does not include full topology.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +365,8 @@ PrimvarRefiner::LimitFaceVarying(T const & src, U & dst, int channel) const {
|
|||||||
|
|
||||||
if (_refiner.getLevel(_refiner.GetMaxLevel()).getNumVertexEdgesTotal() == 0) {
|
if (_refiner.getLevel(_refiner.GetMaxLevel()).getNumVertexEdgesTotal() == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR,
|
||||||
"Cannot compute limit points -- last level of refinement does not include full topology.");
|
"Failure in PrimvarRefiner::LimitFaceVarying() -- "
|
||||||
|
"last level of refinement does not include full topology.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,9 +94,9 @@ PtexIndices::GetAdjacency(
|
|||||||
|
|
||||||
if (Sdc::SchemeTypeTraits::GetRegularFaceSize(
|
if (Sdc::SchemeTypeTraits::GetRegularFaceSize(
|
||||||
refiner.GetSchemeType()) != 4) {
|
refiner.GetSchemeType()) != 4) {
|
||||||
Far::Error(FAR_CODING_ERROR,
|
Far::Error(FAR_RUNTIME_ERROR,
|
||||||
"PtexIndices::GetAdjacency() is currently only implemented for "
|
"Failure in PtexIndices::GetAdjacency() -- "
|
||||||
"quad schemes.");
|
"currently only implemented for quad schemes.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,12 +192,12 @@ TopologyRefiner::RefineUniform(UniformOptions options) {
|
|||||||
|
|
||||||
if (_levels[0]->getNumVertices() == 0) {
|
if (_levels[0]->getNumVertices() == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR,
|
||||||
"Cannot apply uniform refinement -- base level appears to be uninitialized.");
|
"Failure in TopologyRefiner::RefineUniform() -- base level is uninitialized.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_refinements.size()) {
|
if (_refinements.size()) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR,
|
||||||
"Cannot apply uniform refinement -- previous refinements already applied.");
|
"Failure in TopologyRefiner::RefineUniform() -- previous refinements already applied.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,17 +245,17 @@ TopologyRefiner::RefineAdaptive(AdaptiveOptions options) {
|
|||||||
|
|
||||||
if (_levels[0]->getNumVertices() == 0) {
|
if (_levels[0]->getNumVertices() == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR,
|
||||||
"Cannot apply adaptive refinement -- base level appears to be uninitialized.");
|
"Failure in TopologyRefiner::RefineAdaptive() -- base level is uninitialized.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_refinements.size()) {
|
if (_refinements.size()) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR,
|
||||||
"Cannot apply adaptive refinement -- previous refinements already applied.");
|
"Failure in TopologyRefiner::RefineAdaptive() -- previous refinements already applied.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_subdivType != Sdc::SCHEME_CATMARK) {
|
if (_subdivType != Sdc::SCHEME_CATMARK) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR,
|
||||||
"Cannot apply adaptive refinement -- currently only supported for scheme Catmark.");
|
"Failure in TopologyRefiner::RefineAdaptive() -- currently only supported for Catmark scheme.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,13 +57,13 @@ TopologyRefinerFactoryBase::prepareComponentTopologySizing(TopologyRefiner& refi
|
|||||||
int fCount = baseLevel.getNumFaces();
|
int fCount = baseLevel.getNumFaces();
|
||||||
|
|
||||||
if (vCount == 0) {
|
if (vCount == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
"Invalid topology detected : mesh contains no vertices.");
|
"mesh contains no vertices.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (fCount == 0) {
|
if (fCount == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
"Invalid topology detected : meshes without faces not yet supported.");
|
"meshes without faces not yet supported.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,8 +71,8 @@ TopologyRefinerFactoryBase::prepareComponentTopologySizing(TopologyRefiner& refi
|
|||||||
// valence has been initialized with the maximum number of face-vertices:
|
// valence has been initialized with the maximum number of face-vertices:
|
||||||
if (baseLevel.getMaxValence() > Vtr::VALENCE_LIMIT) {
|
if (baseLevel.getMaxValence() > Vtr::VALENCE_LIMIT) {
|
||||||
char msg[1024];
|
char msg[1024];
|
||||||
snprintf(msg, 1024,
|
snprintf(msg, 1024, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
"Invalid topology specified : face with %d vertices > %d max.",
|
"face with %d vertices > %d max.",
|
||||||
baseLevel.getMaxValence(), Vtr::VALENCE_LIMIT);
|
baseLevel.getMaxValence(), Vtr::VALENCE_LIMIT);
|
||||||
Error(FAR_RUNTIME_ERROR, msg);
|
Error(FAR_RUNTIME_ERROR, msg);
|
||||||
return false;
|
return false;
|
||||||
@ -82,13 +82,13 @@ TopologyRefinerFactoryBase::prepareComponentTopologySizing(TopologyRefiner& refi
|
|||||||
baseLevel.getOffsetOfFaceVertices(fCount - 1);
|
baseLevel.getOffsetOfFaceVertices(fCount - 1);
|
||||||
|
|
||||||
if (fVertCount == 0) {
|
if (fVertCount == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
"Invalid topology detected : mesh contains no face-vertices.");
|
"mesh contains no face-vertices.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((refiner.GetSchemeType() == Sdc::SCHEME_LOOP) && (fVertCount != (3 * fCount))) {
|
if ((refiner.GetSchemeType() == Sdc::SCHEME_LOOP) && (fVertCount != (3 * fCount))) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
"Invalid topology specified : non-triangular faces not supported by Loop scheme.");
|
"non-triangular faces not supported by Loop scheme.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
baseLevel.resizeFaceVertices(fVertCount);
|
baseLevel.resizeFaceVertices(fVertCount);
|
||||||
@ -127,25 +127,29 @@ TopologyRefinerFactoryBase::prepareComponentTopologyAssignment(TopologyRefiner&
|
|||||||
if (completeMissingTopology) {
|
if (completeMissingTopology) {
|
||||||
if (not baseLevel.completeTopologyFromFaceVertices()) {
|
if (not baseLevel.completeTopologyFromFaceVertices()) {
|
||||||
char msg[1024];
|
char msg[1024];
|
||||||
snprintf(msg, 1024,
|
snprintf(msg, 1024, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
"Invalid topology detected : vertex with valence %d > %d max.",
|
"vertex with valence %d > %d max.",
|
||||||
baseLevel.getMaxValence(), Vtr::VALENCE_LIMIT);
|
baseLevel.getMaxValence(), Vtr::VALENCE_LIMIT);
|
||||||
Error(FAR_RUNTIME_ERROR, msg);
|
Error(FAR_RUNTIME_ERROR, msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (baseLevel.getMaxValence() == 0) {
|
if (baseLevel.getMaxValence() == 0) {
|
||||||
Error(FAR_RUNTIME_ERROR,
|
Error(FAR_RUNTIME_ERROR, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
"Invalid topology detected : maximum valence not assigned.");
|
"maximum valence not assigned.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullValidation) {
|
if (fullValidation) {
|
||||||
if (not baseLevel.validateTopology(callback, callbackData)) {
|
if (not baseLevel.validateTopology(callback, callbackData)) {
|
||||||
Error(FAR_RUNTIME_ERROR, completeMissingTopology ?
|
if (completeMissingTopology) {
|
||||||
"Invalid topology detected as completed from partial specification." :
|
Error(FAR_RUNTIME_ERROR, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
"Invalid topology detected as fully specified.");
|
"invalid topology detected from partial specification.");
|
||||||
|
} else {
|
||||||
|
Error(FAR_RUNTIME_ERROR, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
|
"invalid topology detected as fully specified.");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +293,8 @@ TopologyRefinerFactoryBase::prepareFaceVaryingChannels(TopologyRefiner& refiner)
|
|||||||
for (int channel=0; channel<refiner.GetNumFVarChannels(); ++channel) {
|
for (int channel=0; channel<refiner.GetNumFVarChannels(); ++channel) {
|
||||||
if (baseLevel.getNumFVarValues(channel) == 0) {
|
if (baseLevel.getNumFVarValues(channel) == 0) {
|
||||||
char msg[1024];
|
char msg[1024];
|
||||||
snprintf(msg, 1024, "Invalid face-varying channel : channel %d has no values.", channel);
|
snprintf(msg, 1024, "Failure in TopologyRefinerFactory<>::Create() -- "
|
||||||
|
"face-varying channel %d has no values.", channel);
|
||||||
Error(FAR_RUNTIME_ERROR, msg);
|
Error(FAR_RUNTIME_ERROR, msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,8 @@ template <class MESH>
|
|||||||
bool
|
bool
|
||||||
TopologyRefinerFactory<MESH>::resizeComponentTopology(TopologyRefiner& /* refiner */, MESH const& /* mesh */) {
|
TopologyRefinerFactory<MESH>::resizeComponentTopology(TopologyRefiner& /* refiner */, MESH const& /* mesh */) {
|
||||||
|
|
||||||
Error(FAR_RUNTIME_ERROR, "Missing specialization for TopologyRefinerFactory<MESH>::resizeComponentTopology()");
|
Error(FAR_RUNTIME_ERROR,
|
||||||
|
"Failure in TopologyRefinerFactory<>::resizeComponentTopology() -- no specialization provided.");
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sizing the topology tables:
|
// Sizing the topology tables:
|
||||||
@ -587,7 +588,8 @@ template <class MESH>
|
|||||||
bool
|
bool
|
||||||
TopologyRefinerFactory<MESH>::assignComponentTopology(TopologyRefiner& /* refiner */, MESH const& /* mesh */) {
|
TopologyRefinerFactory<MESH>::assignComponentTopology(TopologyRefiner& /* refiner */, MESH const& /* mesh */) {
|
||||||
|
|
||||||
Error(FAR_RUNTIME_ERROR, "Missing specialization for TopologyRefinerFactory<MESH>::assignComponentTopology()");
|
Error(FAR_RUNTIME_ERROR,
|
||||||
|
"Failure in TopologyRefinerFactory<>::assignComponentTopology() -- no specialization provided.");
|
||||||
|
|
||||||
//
|
//
|
||||||
// Assigning the topology tables:
|
// Assigning the topology tables:
|
||||||
|
Loading…
Reference in New Issue
Block a user