Skip to content

Commit 54e00db

Browse files
committed
[fcelib][Python] rewrite version check, reduce fluff, refactor api
1 parent 384493b commit 54e00db

11 files changed

Lines changed: 772 additions & 659 deletions

File tree

python/fcecodecmodule.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ class Mesh : public FcelibMesh
5656
Mesh() : mesh_(*this) { FCELIB_MeshInit(&mesh_); }
5757
~Mesh() { FCELIB_MeshRelease(&mesh_); }
5858

59+
#if !defined(SCL_DEBUG) || SCL_DEBUG != 0
5960
// Service
60-
bool MValid() const { return FCELIB_ValidateMesh(&mesh_); }
61+
bool MValid() const { return FCELIB_MeshValidate(&mesh_); }
62+
#endif
6163

6264
// Stats
6365
void PrintInfo() const { FCELIB_PrintMeshInfo(&mesh_); }
66+
#if !defined(SCL_DEBUG) || SCL_DEBUG != 0
6467
void PrintParts(void) const { FCELIB_PrintMeshParts(&mesh_); }
6568
void PrintTriags(void) const { FCELIB_PrintMeshTriangles(&mesh_); }
6669
void PrintVerts(void) const { FCELIB_PrintMeshVertices(&mesh_); }
70+
#endif
6771
int MNumParts() const { return mesh_.hdr.NumParts; }
6872
int MNumTriags() const { return mesh_.hdr.NumTriangles; }
6973
int MNumVerts() const { return mesh_.hdr.NumVertices; }
@@ -1090,7 +1094,8 @@ bool Mesh::OpDeletePart(const int pid)
10901094
{
10911095
if (pid > mesh_.hdr.NumParts || pid < 0)
10921096
throw std::out_of_range("OpDeletePart: part index (pid) out of range");
1093-
return FCELIB_DeletePart(&mesh_, pid);
1097+
FCELIB_DeletePart(&mesh_, pid);
1098+
return 1;
10941099
}
10951100

10961101
bool Mesh::OpDeletePartTriags(const int pid, const std::vector<int> &idxs)
@@ -1149,17 +1154,21 @@ PYBIND11_MODULE(fcecodec, fcecodec_module, py::mod_gil_not_used())
11491154

11501155
fcecodec_module.def("GetFceVersion", &FCECODECMODULE_GetFceVersion, py::arg("buf"), R"pbdoc( Returns 3 (FCE3), 4 (FCE4), 5 (FCE4M), negative (invalid) )pbdoc");
11511156
fcecodec_module.def("PrintFceInfo", &FCECODECMODULE_PrintFceInfo, py::arg("buf"));
1152-
fcecodec_module.def("ValidateFce", &FCECODECMODULE_ValidateFce, py::arg("buf"), R"pbdoc( Returns 1 for valid FCE data, 0 otherwise. )pbdoc");
1157+
fcecodec_module.def("ValidateFce", &FCECODECMODULE_ValidateFce, py::arg("buf"), R"pbdoc( DEPRECATED as of 1.15 Returns 1 for valid FCE data, 0 otherwise. )pbdoc"); /* DEPRECATED as of 1.15 */
11531158

11541159
py::class_<Mesh>(fcecodec_module, "Mesh", py::buffer_protocol())
11551160
.def(py::init<>())
11561161

1162+
#if !defined(SCL_DEBUG) || SCL_DEBUG != 0
11571163
.def("MValid", &Mesh::MValid)
1164+
#endif
11581165

11591166
.def("PrintInfo", &Mesh::PrintInfo)
1167+
#if !defined(SCL_DEBUG) || SCL_DEBUG != 0
11601168
.def("PrintParts", &Mesh::PrintParts)
11611169
.def("PrintTriags", &Mesh::PrintTriags)
11621170
.def("PrintVerts", &Mesh::PrintVerts)
1171+
#endif
11631172
.def_property_readonly("MNumParts", &Mesh::MNumParts)
11641173
.def_property_readonly("MNumTriags", &Mesh::MNumTriags)
11651174
.def_property_readonly("MNumVerts", &Mesh::MNumVerts)

scripts/bfut_mywrappers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ def GetFceVersion(path):
6060
return version
6161

6262
def PrintFceInfo(path):
63-
buf = fc.GetFceVersion(pathlib.Path(path).read_bytes())
63+
buf = pathlib.Path(path).read_bytes()
6464
fc.PrintFceInfo(buf)
65-
assert fc.ValidateFce(buf) == 1
6665

6766
def LoadFce(mesh, path):
6867
mesh.IoDecode(pathlib.Path(path).read_bytes())
@@ -135,7 +134,7 @@ def FilterTexpageTriags(mesh, drop_texpages: int | list | None = None, select_te
135134
else:
136135
raise ValueError("FilterTexpageTriags: call with either drop_texpages or select_texpages, not both")
137136

138-
assert mesh.OpDelUnrefdVerts()
137+
# assert mesh.OpDelUnrefdVerts()
139138
return mesh
140139

141140
def DeleteEmptyParts(mesh):

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
# Available at setup time due to pyproject.toml
3030
from pybind11.setup_helpers import Pybind11Extension, build_ext
3131

32-
if os.environ.get("FCECVERBOSE") is not None:
33-
print(f'FCECVERBOSE={os.environ["FCECVERBOSE"]}')
32+
if os.environ.get("SCL_DEBUG") is not None:
33+
print(f'SCL_DEBUG={os.environ["SCL_DEBUG"]}')
3434

3535
script_path = pathlib.Path(__file__).parent.resolve()
3636
os.chdir(script_path)
@@ -137,7 +137,7 @@
137137
# https://github.com/pybind/python_example/issues/12
138138
# https://github.com/pybind/python_example/blob/master/src/main.cpp
139139
("VERSION_INFO", __version__),
140-
("FCECVERBOSE", os.environ.get("FCECVERBOSE", 0)), # 0 if key not set
140+
("SCL_DEBUG", os.environ.get("SCL_DEBUG", 0)), # 0 if key not set
141141
],
142142
extra_compile_args=extra_compile_args
143143
),

0 commit comments

Comments
 (0)