From b7470bb26f108339ddaeb46ee1cf8840b04e3a4b Mon Sep 17 00:00:00 2001 From: barry Date: Tue, 23 Apr 2019 12:05:14 -0700 Subject: [PATCH] Moved definition of struct ShapeDesc into same header file as Shape: - added definition to regression/common/shape_utils.h - removed examples/common/shapeDesc.h and all references to it - removed local definitions of ShapeDesc from examples, regressions, etc. - overloaded Shape::parseObj() with ShapeDesc - updated examples to use Shape::parseObj(ShapeDesc const&); - removed axis argument to Shape::ParseObj() and ObjAnim::Create() --- examples/common/CMakeLists.txt | 1 - examples/common/objAnim.cpp | 4 +- examples/common/objAnim.h | 4 +- examples/common/shapeDesc.h | 44 ------- examples/common/viewerArgsUtils.cpp | 3 +- examples/common/viewerArgsUtils.h | 1 - examples/dxViewer/dxviewer.cpp | 2 +- examples/dxViewer/init_shapes.h | 1 - examples/farViewer/farViewer.cpp | 2 +- examples/farViewer/init_shapes.h | 9 -- examples/glEvalLimit/glEvalLimit.cpp | 2 +- examples/glEvalLimit/init_shapes.h | 9 -- examples/glFVarViewer/glFVarViewer.cpp | 2 +- examples/glFVarViewer/init_shapes.h | 2 +- examples/glImaging/glImaging.cpp | 3 +- examples/glImaging/init_shapes.h | 9 -- examples/glPaintTest/glPaintTest.cpp | 2 +- examples/glPaintTest/init_shapes.h | 9 -- examples/glShareTopology/glShareTopology.cpp | 5 +- examples/glShareTopology/init_shapes.h | 11 -- examples/glStencilViewer/glStencilViewer.cpp | 2 +- examples/glStencilViewer/init_shapes.h | 9 -- examples/glViewer/glViewer.cpp | 3 +- examples/glViewer/init_shapes.h | 1 - examples/mtlPtexViewer/init_shapes.h | 11 -- examples/mtlViewer/init_shapes.h | 11 -- regression/common/shape_utils.cpp | 18 +-- regression/common/shape_utils.h | 19 ++- regression/far_perf/far_perf.cpp | 5 +- regression/far_perf/init_shapes.h | 14 +- regression/far_regression/far_regression.cpp | 8 +- regression/far_regression/init_shapes.h | 11 -- regression/hbr_regression/init_shapes.h | 127 ++++++------------- regression/hbr_regression/main.cpp | 4 +- 34 files changed, 95 insertions(+), 273 deletions(-) delete mode 100644 examples/common/shapeDesc.h diff --git a/examples/common/CMakeLists.txt b/examples/common/CMakeLists.txt index 50d6618d..2e425a34 100644 --- a/examples/common/CMakeLists.txt +++ b/examples/common/CMakeLists.txt @@ -46,7 +46,6 @@ set(EXAMPLES_COMMON_HEADER_FILES objAnim.h patchColors.h shaderCache.h - shapeDesc.h simple_math.h stb_image_write.h stopwatch.h diff --git a/examples/common/objAnim.cpp b/examples/common/objAnim.cpp index 92f51778..8f08d93a 100644 --- a/examples/common/objAnim.cpp +++ b/examples/common/objAnim.cpp @@ -88,7 +88,7 @@ ObjAnim::InterpolatePositions(float time, float * positions, int stride) const { } ObjAnim const * -ObjAnim::Create(std::vector objFiles, bool axis, Scheme scheme) { +ObjAnim::Create(std::vector objFiles, Scheme scheme, bool isLeftHanded) { ObjAnim * anim=0; @@ -118,7 +118,7 @@ ObjAnim::Create(std::vector objFiles, bool axis, Scheme scheme) { fflush(stdout); std::string str = ss.str(); - shape = Shape::parseObj(str.c_str(), scheme, false, axis); + shape = Shape::parseObj(str.c_str(), scheme, isLeftHanded); if (i==0) { diff --git a/examples/common/objAnim.h b/examples/common/objAnim.h index a012fcb6..df28a863 100644 --- a/examples/common/objAnim.h +++ b/examples/common/objAnim.h @@ -34,8 +34,8 @@ class ObjAnim { public: // Factory function - static ObjAnim const * Create(std::vector objFiles, bool axis=true, - Scheme scheme=kCatmark); + static ObjAnim const * Create(std::vector objFiles, + Scheme scheme, bool isLeftHanded=false); // Destructor ~ObjAnim(); diff --git a/examples/common/shapeDesc.h b/examples/common/shapeDesc.h deleted file mode 100644 index e8af0c2c..00000000 --- a/examples/common/shapeDesc.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright 2019 Pixar -// -// Licensed under the Apache License, Version 2.0 (the "Apache License") -// with the following modification; you may not use this file except in -// compliance with the Apache License and the following modification to it: -// Section 6. Trademarks. is deleted and replaced with: -// -// 6. Trademarks. This License does not grant permission to use the trade -// names, trademarks, service marks, or product names of the Licensor -// and its affiliates, except as required to comply with Section 4(c) of -// the License and to reproduce the content of the NOTICE file. -// -// You may obtain a copy of the Apache License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the Apache License with the above modification is -// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the Apache License for the specific -// language governing permissions and limitations under the Apache License. -// - -#ifndef SHAPE_DESC_H -#define SHAPE_DESC_H - - -#include - -struct ShapeDesc -{ - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme, - bool iIsLeftHanded = false) : - name(iname), data(idata), scheme(ischeme), isLeftHanded(iIsLeftHanded) - { } - - std::string name; - std::string data; - Scheme scheme; - bool isLeftHanded; -}; - -#endif // SHAPE_DESC_H diff --git a/examples/common/viewerArgsUtils.cpp b/examples/common/viewerArgsUtils.cpp index 3966bf9a..cea2ddab 100644 --- a/examples/common/viewerArgsUtils.cpp +++ b/examples/common/viewerArgsUtils.cpp @@ -25,7 +25,6 @@ #include "../common/viewerArgsUtils.h" #include "../common/objAnim.h" -#include "../common/shapeDesc.h" #include #include @@ -43,7 +42,7 @@ PopulateAnimShapes(const ArgOptions &args, return NULL; - const ObjAnim *objAnim = ObjAnim::Create(args.GetObjFiles(), true, + const ObjAnim *objAnim = ObjAnim::Create(args.GetObjFiles(), args.GetDefaultScheme()); if (objAnim) { diff --git a/examples/common/viewerArgsUtils.h b/examples/common/viewerArgsUtils.h index 6c4e16f2..e1df4b4e 100644 --- a/examples/common/viewerArgsUtils.h +++ b/examples/common/viewerArgsUtils.h @@ -28,7 +28,6 @@ #include "../../regression/common/shape_utils.h" #include "../common/argOptions.h" -#include "../common/shapeDesc.h" class ObjAnim; diff --git a/examples/dxViewer/dxviewer.cpp b/examples/dxViewer/dxviewer.cpp index 2857d81d..4dceb4fa 100644 --- a/examples/dxViewer/dxviewer.cpp +++ b/examples/dxViewer/dxviewer.cpp @@ -271,7 +271,7 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level, int kernel, Scheme scheme= using namespace OpenSubdiv; typedef Far::ConstIndexArray IndexArray; - Shape * shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme); + Shape * shape = Shape::parseObj(shapeDesc); // create Far mesh (topology) Sdc::SchemeType sdctype = GetSdcType(*shape); diff --git a/examples/dxViewer/init_shapes.h b/examples/dxViewer/init_shapes.h index f85657ee..ea9c1f66 100644 --- a/examples/dxViewer/init_shapes.h +++ b/examples/dxViewer/init_shapes.h @@ -25,7 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -#include "../common/shapeDesc.h" static std::vector g_defaultShapes; diff --git a/examples/farViewer/farViewer.cpp b/examples/farViewer/farViewer.cpp index 06ae1a96..732429df 100644 --- a/examples/farViewer/farViewer.cpp +++ b/examples/farViewer/farViewer.cpp @@ -812,7 +812,7 @@ createMeshes(ShapeDesc const & desc, int maxlevel) { } g_font->Clear(); - Shape * shape = Shape::parseObj(desc.data.c_str(), desc.scheme); + Shape * shape = Shape::parseObj(desc); createFarGLMesh(shape, maxlevel); delete shape; diff --git a/examples/farViewer/init_shapes.h b/examples/farViewer/init_shapes.h index 96f50c32..7cbdab87 100644 --- a/examples/farViewer/init_shapes.h +++ b/examples/farViewer/init_shapes.h @@ -25,15 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme) : - name(iname), data(idata), scheme(ischeme) { } - - std::string name, - data; - Scheme scheme; -}; static std::vector g_shapes; diff --git a/examples/glEvalLimit/glEvalLimit.cpp b/examples/glEvalLimit/glEvalLimit.cpp index b350f11f..7ef023d0 100644 --- a/examples/glEvalLimit/glEvalLimit.cpp +++ b/examples/glEvalLimit/glEvalLimit.cpp @@ -605,7 +605,7 @@ updateGeom() { static void createOsdMesh(ShapeDesc const & shapeDesc, int level) { - Shape * shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme); + Shape * shape = Shape::parseObj(shapeDesc); // create Far mesh (topology) Sdc::SchemeType sdctype = GetSdcType(*shape); diff --git a/examples/glEvalLimit/init_shapes.h b/examples/glEvalLimit/init_shapes.h index 78d33a70..62d2d496 100644 --- a/examples/glEvalLimit/init_shapes.h +++ b/examples/glEvalLimit/init_shapes.h @@ -25,15 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme) : - name(iname), data(idata), scheme(ischeme) { } - - std::string name, - data; - Scheme scheme; -}; static std::vector g_defaultShapes; diff --git a/examples/glFVarViewer/glFVarViewer.cpp b/examples/glFVarViewer/glFVarViewer.cpp index f788a2d3..507eb8ed 100644 --- a/examples/glFVarViewer/glFVarViewer.cpp +++ b/examples/glFVarViewer/glFVarViewer.cpp @@ -414,7 +414,7 @@ rebuildMesh() { int level = g_level; Scheme scheme = g_defaultShapes[g_currentShape].scheme; - Shape * shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme); + Shape * shape = Shape::parseObj(shapeDesc); if (!shape->HasUV()) { printf("Error: shape %s does not contain face-varying UVs\n", shapeDesc.name.c_str()); diff --git a/examples/glFVarViewer/init_shapes.h b/examples/glFVarViewer/init_shapes.h index bc6de15c..403137fe 100644 --- a/examples/glFVarViewer/init_shapes.h +++ b/examples/glFVarViewer/init_shapes.h @@ -24,7 +24,7 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -#include "../common/shapeDesc.h" + static std::vector g_defaultShapes; diff --git a/examples/glImaging/glImaging.cpp b/examples/glImaging/glImaging.cpp index 7f36cef4..30b727ce 100644 --- a/examples/glImaging/glImaging.cpp +++ b/examples/glImaging/glImaging.cpp @@ -300,8 +300,7 @@ void runTest(ShapeDesc const &shapeDesc, std::string const &kernel, std::cout << "Testing " << shapeDesc.name << ", kernel = " << kernel << "\n"; - Shape const * shape = Shape::parseObj(shapeDesc.data.c_str(), - shapeDesc.scheme); + Shape const * shape = Shape::parseObj(shapeDesc); // create Far mesh (topology) Sdc::SchemeType sdctype = GetSdcType(*shape); diff --git a/examples/glImaging/init_shapes.h b/examples/glImaging/init_shapes.h index c502d859..44f055f4 100644 --- a/examples/glImaging/init_shapes.h +++ b/examples/glImaging/init_shapes.h @@ -25,15 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme) : - name(iname), data(idata), scheme(ischeme) { } - - std::string name, - data; - Scheme scheme; -}; static std::vector g_shapes; diff --git a/examples/glPaintTest/glPaintTest.cpp b/examples/glPaintTest/glPaintTest.cpp index 9e3d4dd4..651448a8 100644 --- a/examples/glPaintTest/glPaintTest.cpp +++ b/examples/glPaintTest/glPaintTest.cpp @@ -197,7 +197,7 @@ createOsdMesh() { ShapeDesc const & shapeDesc = g_defaultShapes[g_currentShape]; - Shape * shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme); + Shape * shape = Shape::parseObj(shapeDesc); checkGLErrors("create osd enter"); diff --git a/examples/glPaintTest/init_shapes.h b/examples/glPaintTest/init_shapes.h index e07a22b6..9d1be653 100644 --- a/examples/glPaintTest/init_shapes.h +++ b/examples/glPaintTest/init_shapes.h @@ -25,15 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme) : - name(iname), data(idata), scheme(ischeme) { } - - std::string name, - data; - Scheme scheme; -}; static std::vector g_defaultShapes; diff --git a/examples/glShareTopology/glShareTopology.cpp b/examples/glShareTopology/glShareTopology.cpp index 77e2785c..6b0ab735 100644 --- a/examples/glShareTopology/glShareTopology.cpp +++ b/examples/glShareTopology/glShareTopology.cpp @@ -932,10 +932,7 @@ rebuildTopology() { } for (int i = 0; i < (int)g_defaultShapes.size(); ++i) { - Shape const * shape = Shape::parseObj( - g_defaultShapes[i].data.c_str(), - g_defaultShapes[i].scheme, - g_defaultShapes[i].isLeftHanded); + Shape const * shape = Shape::parseObj(g_defaultShapes[i]); bool varying = (g_displayStyle==kVarying || g_displayStyle==kVaryingInterleaved); g_scene->AddTopology(shape, g_level, varying); diff --git a/examples/glShareTopology/init_shapes.h b/examples/glShareTopology/init_shapes.h index 8d9ab2b5..156d1444 100644 --- a/examples/glShareTopology/init_shapes.h +++ b/examples/glShareTopology/init_shapes.h @@ -25,17 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme, - bool iIsLeftHanded=false) : - name(iname), data(idata), scheme(ischeme), isLeftHanded(iIsLeftHanded) { } - - std::string name, - data; - Scheme scheme; - bool isLeftHanded; -}; static std::vector g_defaultShapes; diff --git a/examples/glStencilViewer/glStencilViewer.cpp b/examples/glStencilViewer/glStencilViewer.cpp index cece319b..fa98521f 100644 --- a/examples/glStencilViewer/glStencilViewer.cpp +++ b/examples/glStencilViewer/glStencilViewer.cpp @@ -293,7 +293,7 @@ createMesh(ShapeDesc const & shapeDesc, int level) { typedef Far::LimitStencilTableFactory::LocationArray LocationArray; - Shape const * shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme); + Shape const * shape = Shape::parseObj(shapeDesc); // create Far mesh (topology) Sdc::SchemeType sdctype = GetSdcType(*shape); diff --git a/examples/glStencilViewer/init_shapes.h b/examples/glStencilViewer/init_shapes.h index a2cdd867..a6354333 100644 --- a/examples/glStencilViewer/init_shapes.h +++ b/examples/glStencilViewer/init_shapes.h @@ -25,15 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme) : - name(iname), data(idata), scheme(ischeme) { } - - std::string name, - data; - Scheme scheme; -}; static std::vector g_defaultShapes; diff --git a/examples/glViewer/glViewer.cpp b/examples/glViewer/glViewer.cpp index 398829f7..df15c61f 100644 --- a/examples/glViewer/glViewer.cpp +++ b/examples/glViewer/glViewer.cpp @@ -428,8 +428,7 @@ rebuildMesh() { if (doAnim) { shape = g_objAnim->GetShape(); } else { - shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme, - shapeDesc.isLeftHanded); + shape = Shape::parseObj(shapeDesc); } // create Far mesh (topology) diff --git a/examples/glViewer/init_shapes.h b/examples/glViewer/init_shapes.h index f85657ee..ea9c1f66 100644 --- a/examples/glViewer/init_shapes.h +++ b/examples/glViewer/init_shapes.h @@ -25,7 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -#include "../common/shapeDesc.h" static std::vector g_defaultShapes; diff --git a/examples/mtlPtexViewer/init_shapes.h b/examples/mtlPtexViewer/init_shapes.h index 7431f184..ec85f128 100644 --- a/examples/mtlPtexViewer/init_shapes.h +++ b/examples/mtlPtexViewer/init_shapes.h @@ -25,17 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme, - bool iIsLeftHanded = false) : - name(iname), data(idata), scheme(ischeme), isLeftHanded(iIsLeftHanded) { } - - std::string name, - data; - Scheme scheme; - bool isLeftHanded; -}; static std::vector g_defaultShapes; diff --git a/examples/mtlViewer/init_shapes.h b/examples/mtlViewer/init_shapes.h index c4cfc83c..ea9c1f66 100644 --- a/examples/mtlViewer/init_shapes.h +++ b/examples/mtlViewer/init_shapes.h @@ -25,17 +25,6 @@ #include "../../regression/common/shape_utils.h" #include "../../regression/shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme, - bool iIsLeftHanded = false) : - name(iname), data(idata), scheme(ischeme), isLeftHanded(iIsLeftHanded) { } - - std::string name; - std::string data; - Scheme scheme; - bool isLeftHanded; -}; static std::vector g_defaultShapes; diff --git a/regression/common/shape_utils.cpp b/regression/common/shape_utils.cpp index d27beca5..4d049b8e 100644 --- a/regression/common/shape_utils.cpp +++ b/regression/common/shape_utils.cpp @@ -61,8 +61,8 @@ Shape::~Shape() { } //------------------------------------------------------------------------------ -Shape * Shape::parseObj(char const * shapestr, Scheme shapescheme, - bool isLeftHanded, int axis, bool parsemtl) { +Shape * Shape::parseObj(char const * shapestr, Scheme shapescheme, bool isLeftHanded, + bool parsemtl) { Shape * s = new Shape; @@ -82,12 +82,8 @@ Shape * Shape::parseObj(char const * shapestr, Scheme shapescheme, case 'v': switch (line[1]) { case ' ': if (sscanf(line, "v %f %f %f", &x, &y, &z) == 3) { s->verts.push_back(x); - switch( axis ) { - case 0 : s->verts.push_back(-z); - s->verts.push_back(y); break; - case 1 : s->verts.push_back(y); - s->verts.push_back(z); break; - } + s->verts.push_back(y); + s->verts.push_back(z); } break; case 't': if (sscanf(line, "vt %f %f", &u, &v) == 2) { s->uvs.push_back(u); @@ -141,6 +137,12 @@ Shape * Shape::parseObj(char const * shapestr, Scheme shapescheme, return s; } +//------------------------------------------------------------------------------ +Shape * Shape::parseObj(ShapeDesc const & shapeDesc, bool parsemtl) { + return parseObj(shapeDesc.data.c_str(), shapeDesc.scheme, shapeDesc.isLeftHanded, + parsemtl); +} + //------------------------------------------------------------------------------ Shape::tag * Shape::tag::parseTag(char const * line) { tag * t = 0; diff --git a/regression/common/shape_utils.h b/regression/common/shape_utils.h index cd3e7a77..07e9682b 100644 --- a/regression/common/shape_utils.h +++ b/regression/common/shape_utils.h @@ -30,12 +30,26 @@ #include //------------------------------------------------------------------------------ + enum Scheme { kBilinear=0, kCatmark, kLoop }; +struct ShapeDesc +{ + ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme, + bool iIsLeftHanded = false) : + name(iname), data(idata), scheme(ischeme), isLeftHanded(iIsLeftHanded) + { } + + std::string name; + std::string data; + Scheme scheme; + bool isLeftHanded; +}; + //------------------------------------------------------------------------------ struct Shape { @@ -70,8 +84,9 @@ struct Shape { std::vector stringargs; }; - static Shape * parseObj(char const * Shapestr, Scheme schme, - bool isLeftHanded=false, int axis=1, bool parsemtl=false); + static Shape * parseObj(ShapeDesc const & shapeDesc, bool parsemtl=false); + static Shape * parseObj(char const * shapeString, Scheme shapeScheme, + bool isLeftHanded=false, bool parsemtl=false); void parseMtllib(char const * stream); diff --git a/regression/far_perf/far_perf.cpp b/regression/far_perf/far_perf.cpp index 85de8787..a38371ea 100644 --- a/regression/far_perf/far_perf.cpp +++ b/regression/far_perf/far_perf.cpp @@ -165,10 +165,7 @@ int main(int argc, char **argv) } for (int i = 0; i < (int)g_shapes.size(); ++i) { - Shape const * shape = Shape::parseObj( - g_shapes[i].data.c_str(), - g_shapes[i].scheme, - g_shapes[i].isLeftHanded); + Shape const * shape = Shape::parseObj(g_shapes[i]); for (int lv = 1; lv <= maxlevel; ++lv) { printf("---- %s, level %d ----\n", g_shapes[i].name.c_str(), lv); diff --git a/regression/far_perf/init_shapes.h b/regression/far_perf/init_shapes.h index 40d37225..631fc69a 100644 --- a/regression/far_perf/init_shapes.h +++ b/regression/far_perf/init_shapes.h @@ -23,23 +23,11 @@ // #include "../common/shape_utils.h" +#include "../shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme, - bool iisLeftHanded=false) : - name(iname), data(idata), scheme(ischeme), isLeftHanded(iisLeftHanded) { } - - std::string name, - data; - Scheme scheme; - bool isLeftHanded; -}; static std::vector g_shapes; -#include "../shapes/all.h" - //------------------------------------------------------------------------------ static void initShapes() { g_shapes.push_back( ShapeDesc("catmark_car", catmark_car, kCatmark ) ); diff --git a/regression/far_regression/far_regression.cpp b/regression/far_regression/far_regression.cpp index 233248dc..150bde94 100644 --- a/regression/far_regression/far_regression.cpp +++ b/regression/far_regression/far_regression.cpp @@ -297,6 +297,12 @@ areVerticesCompatibleWithHbr(Shape const & shape, FarTopologyRefiner const & ref } return false; } + if (shape.isLeftHanded) { + if (incompatibleString) { + *incompatibleString = std::string("mesh is left-handed"); + } + return false; + } if (shapeHasHierarchicalEditTags(shape)) { if (incompatibleString) { *incompatibleString = std::string("hierarchical edits no longer supported"); @@ -347,7 +353,7 @@ int main(int /* argc */, char ** /* argv */) { for (int i=0; i<(int)g_shapes.size(); ++i) { ShapeDesc const & desc = g_shapes[i]; - Shape * shape = Shape::parseObj(desc.data.c_str(), desc.scheme); + Shape * shape = Shape::parseObj(desc); if (shape) { // May want to inspect and/or modify the shape before proceeding... diff --git a/regression/far_regression/init_shapes.h b/regression/far_regression/init_shapes.h index 9bda1c6e..3d86b094 100644 --- a/regression/far_regression/init_shapes.h +++ b/regression/far_regression/init_shapes.h @@ -25,17 +25,6 @@ #include "../common/shape_utils.h" #include "../shapes/all.h" -struct ShapeDesc { - - ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme, - bool iisLeftHanded=false) : - name(iname), data(idata), scheme(ischeme), isLeftHanded(iisLeftHanded) { } - - std::string name, - data; - Scheme scheme; - bool isLeftHanded; -}; static std::vector g_shapes; diff --git a/regression/hbr_regression/init_shapes.h b/regression/hbr_regression/init_shapes.h index 58b3bf18..3a164651 100644 --- a/regression/hbr_regression/init_shapes.h +++ b/regression/hbr_regression/init_shapes.h @@ -23,95 +23,52 @@ // #include "../common/shape_utils.h" +#include "../shapes/all.h" -struct shaperec { - shaperec(char const * iname, std::string const & idata, Scheme ischeme) : - name(iname), data(idata), scheme(ischeme) { } - - std::string name, - data; - Scheme scheme; -}; - -static std::vector g_shapes; - -#include "../shapes/bilinear_cube.h" -#include "../shapes/catmark_chaikin0.h" -#include "../shapes/catmark_chaikin1.h" -#include "../shapes/catmark_cube_corner0.h" -#include "../shapes/catmark_cube_corner1.h" -#include "../shapes/catmark_cube_corner2.h" -#include "../shapes/catmark_cube_corner3.h" -#include "../shapes/catmark_cube_corner4.h" -#include "../shapes/catmark_cube_creases0.h" -#include "../shapes/catmark_cube_creases1.h" -#include "../shapes/catmark_cube.h" -#include "../shapes/catmark_dart_edgecorner.h" -#include "../shapes/catmark_dart_edgeonly.h" -#include "../shapes/catmark_edgecorner.h" -#include "../shapes/catmark_edgeonly.h" -#include "../shapes/catmark_flap.h" -#include "../shapes/catmark_flap2.h" -#include "../shapes/catmark_pyramid_creases0.h" -#include "../shapes/catmark_pyramid_creases1.h" -#include "../shapes/catmark_pyramid.h" -#include "../shapes/catmark_square_hedit0.h" -#include "../shapes/catmark_square_hedit1.h" -#include "../shapes/catmark_square_hedit2.h" -#include "../shapes/catmark_square_hedit3.h" -#include "../shapes/catmark_tent_creases0.h" -#include "../shapes/catmark_tent_creases1.h" -#include "../shapes/catmark_tent.h" -#include "../shapes/loop_cube_creases0.h" -#include "../shapes/loop_cube_creases1.h" -#include "../shapes/loop_cube.h" -#include "../shapes/loop_icosahedron.h" -#include "../shapes/loop_saddle_edgecorner.h" -#include "../shapes/loop_saddle_edgeonly.h" -#include "../shapes/loop_triangle_edgecorner.h" -#include "../shapes/loop_triangle_edgeonly.h" -#include "../shapes/loop_chaikin0.h" -#include "../shapes/loop_chaikin1.h" +static std::vector g_shapes; //------------------------------------------------------------------------------ +// +// Shapes commented out below have been modified since baseline data was generated: +// static void initShapes() { - g_shapes.push_back( shaperec("bilinear_cube", bilinear_cube, kBilinear) ); - g_shapes.push_back( shaperec("catmark_chaikin0", catmark_chaikin0, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_chaikin1", catmark_chaikin1, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_cube_corner0", catmark_cube_corner0, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_cube_corner1", catmark_cube_corner1, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_cube_corner2", catmark_cube_corner2, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_cube_corner3", catmark_cube_corner3, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_cube_corner4", catmark_cube_corner4, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_cube_creases0", catmark_cube_creases0, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_cube_creases1", catmark_cube_creases1, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_cube", catmark_cube, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_dart_edgecorner", catmark_dart_edgecorner, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_dart_edgeonly", catmark_dart_edgeonly, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_edgecorner", catmark_edgecorner, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_edgeonly", catmark_edgeonly, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_flap", catmark_flap, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_flap2", catmark_flap2, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_pyramid_creases0", catmark_pyramid_creases0, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_pyramid_creases1", catmark_pyramid_creases1, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_pyramid", catmark_pyramid, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_square_hedit0", catmark_square_hedit0, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_square_hedit1", catmark_square_hedit1, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_square_hedit2", catmark_square_hedit2, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_square_hedit3", catmark_square_hedit3, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_tent_creases0", catmark_tent_creases0, kCatmark ) ); - g_shapes.push_back( shaperec("catmark_tent_creases1", catmark_tent_creases1 , kCatmark ) ); - g_shapes.push_back( shaperec("catmark_tent", catmark_tent, kCatmark ) ); - g_shapes.push_back( shaperec("loop_cube_creases0", loop_cube_creases0, kLoop ) ); - g_shapes.push_back( shaperec("loop_cube_creases1", loop_cube_creases1, kLoop ) ); - g_shapes.push_back( shaperec("loop_cube", loop_cube, kLoop ) ); - g_shapes.push_back( shaperec("loop_icosahedron", loop_icosahedron, kLoop ) ); - g_shapes.push_back( shaperec("loop_saddle_edgecorner", loop_saddle_edgecorner, kLoop ) ); - g_shapes.push_back( shaperec("loop_saddle_edgeonly", loop_saddle_edgeonly, kLoop ) ); - g_shapes.push_back( shaperec("loop_triangle_edgecorner", loop_triangle_edgecorner, kLoop ) ); - g_shapes.push_back( shaperec("loop_triangle_edgeonly", loop_triangle_edgeonly, kLoop ) ); - g_shapes.push_back( shaperec("loop_chaikin0", loop_chaikin0, kLoop ) ); - g_shapes.push_back( shaperec("loop_chaikin1", loop_chaikin1, kLoop ) ); + g_shapes.push_back( ShapeDesc("bilinear_cube", bilinear_cube, kBilinear) ); + g_shapes.push_back( ShapeDesc("catmark_chaikin0", catmark_chaikin0, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_chaikin1", catmark_chaikin1, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_cube_corner0", catmark_cube_corner0, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_cube_corner1", catmark_cube_corner1, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_cube_corner2", catmark_cube_corner2, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_cube_corner3", catmark_cube_corner3, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_cube_corner4", catmark_cube_corner4, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_cube_creases0", catmark_cube_creases0, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_cube_creases1", catmark_cube_creases1, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_cube", catmark_cube, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_dart_edgecorner", catmark_dart_edgecorner, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_dart_edgeonly", catmark_dart_edgeonly, kCatmark ) ); +// g_shapes.push_back( ShapeDesc("catmark_edgecorner", catmark_edgecorner, kCatmark ) ); +// g_shapes.push_back( ShapeDesc("catmark_edgeonly", catmark_edgeonly, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_flap", catmark_flap, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_flap2", catmark_flap2, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_pyramid_creases0", catmark_pyramid_creases0, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_pyramid_creases1", catmark_pyramid_creases1, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_pyramid", catmark_pyramid, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_square_hedit0", catmark_square_hedit0, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_square_hedit1", catmark_square_hedit1, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_square_hedit2", catmark_square_hedit2, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_square_hedit3", catmark_square_hedit3, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_tent_creases0", catmark_tent_creases0, kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_tent_creases1", catmark_tent_creases1 , kCatmark ) ); + g_shapes.push_back( ShapeDesc("catmark_tent", catmark_tent, kCatmark ) ); + g_shapes.push_back( ShapeDesc("loop_cube_creases0", loop_cube_creases0, kLoop ) ); + g_shapes.push_back( ShapeDesc("loop_cube_creases1", loop_cube_creases1, kLoop ) ); +// g_shapes.push_back( ShapeDesc("loop_cube", loop_cube, kLoop ) ); + g_shapes.push_back( ShapeDesc("loop_icosahedron", loop_icosahedron, kLoop ) ); + g_shapes.push_back( ShapeDesc("loop_saddle_edgecorner", loop_saddle_edgecorner, kLoop ) ); + g_shapes.push_back( ShapeDesc("loop_saddle_edgeonly", loop_saddle_edgeonly, kLoop ) ); +// g_shapes.push_back( ShapeDesc("loop_triangle_edgecorner", loop_triangle_edgecorner, kLoop ) ); +// g_shapes.push_back( ShapeDesc("loop_triangle_edgeonly", loop_triangle_edgeonly, kLoop ) ); + g_shapes.push_back( ShapeDesc("loop_chaikin0", loop_chaikin0, kLoop ) ); + g_shapes.push_back( ShapeDesc("loop_chaikin1", loop_chaikin1, kLoop ) ); } //------------------------------------------------------------------------------ diff --git a/regression/hbr_regression/main.cpp b/regression/hbr_regression/main.cpp index 8c1c010d..64238f81 100644 --- a/regression/hbr_regression/main.cpp +++ b/regression/hbr_regression/main.cpp @@ -129,7 +129,7 @@ static Shape * readShape( char const * fname, Scheme scheme ) { shapeStr[size]='\0'; - return Shape::parseObj( shapeStr, scheme, false /*isLeftHanded*/, 1 ); + return Shape::parseObj( shapeStr, scheme ); } #define STR(x) x @@ -179,7 +179,7 @@ static void writeObj( const char * fname, xyzmesh const * mesh, } //------------------------------------------------------------------------------ -static int checkMesh( shaperec const & r, int levels ) { +static int checkMesh( ShapeDesc const & r, int levels ) { int count=0;