Skip to content

Commit

Permalink
Add, import, python, and bundle GeomUtil.
Browse files Browse the repository at this point in the history
  • Loading branch information
furby-tm committed Apr 8, 2024
1 parent da24f62 commit 9b6644f
Show file tree
Hide file tree
Showing 162 changed files with 32,138 additions and 30,318 deletions.
45 changes: 45 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ let package = Package(
name: "Glf",
targets: ["Glf"]
),
.library(
name: "GeomUtil",
targets: ["GeomUtil"]
),
// ----- Pixar.UsdImaging -----
.library(
name: "UsdShaders",
Expand Down Expand Up @@ -377,6 +381,11 @@ let package = Package(
type: .dynamic,
targets: ["PyGlf"]
),
.library(
name: "PyGeomUtil",
type: .dynamic,
targets: ["PyGeomUtil"]
),
// ----------------- Apps -----
.executable(
name: "UsdView",
Expand Down Expand Up @@ -424,6 +433,7 @@ let package = Package(
"PyCameraUtil",
"PyPxOsd",
"PyGarch",
"PyGeomUtil",
"PyGlf",
"PyUsdShaders",
]
Expand Down Expand Up @@ -1421,6 +1431,23 @@ let package = Package(
]
),

.target(
name: "GeomUtil",
dependencies: [
.target(name: "Arch"),
.target(name: "Tf"),
.target(name: "Gf"),
.target(name: "Vt"),
.target(name: "PxOsd"),
],
cxxSettings: [
.define("MFB_PACKAGE_NAME", to: "GeomUtil"),
.define("MFB_ALT_PACKAGE_NAME", to: "GeomUtil"),
.define("MFB_PACKAGE_MODULE", to: "GeomUtil"),
.define("GEOMUTIL_EXPORTS", to: "1"),
]
),

.target(
name: "PyTf",
dependencies: [
Expand Down Expand Up @@ -2017,6 +2044,23 @@ let package = Package(
]
),

.target(
name: "PyGeomUtil",
dependencies: [
.target(name: "PixarUSD"),
],
path: "Python/PyGeomUtil",
resources: [
.process("Resources"),
],
publicHeadersPath: "include",
cxxSettings: [
.define("MFB_PACKAGE_NAME", to: "GeomUtil"),
.define("MFB_ALT_PACKAGE_NAME", to: "GeomUtil"),
.define("MFB_PACKAGE_MODULE", to: "GeomUtil"),
]
),

.executableTarget(
name: "UsdView",
dependencies: [
Expand Down Expand Up @@ -2119,6 +2163,7 @@ let package = Package(
.target(name: "HgiInterop"),
.target(name: "Hio"),
.target(name: "Glf"),
.target(name: "GeomUtil"),
// --- usd imaging. ------
.target(name: "UsdShaders"),
// -------- macros. ------
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions Python/PyGeomUtil/include/PyGeomUtil/PyGeomUtil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __PXR_IMAGING_PY_GEOM_UTIL_H__
#define __PXR_IMAGING_PY_GEOM_UTIL_H__

/* no includes. */

#endif // __PXR_IMAGING_PY_GEOM_UTIL_H__
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/pxr.h"
#include "pxr/base/tf/pyModule.h"
#include "pxr/pxrns.h"
#include "Tf/pyModule.h"

PXR_NAMESPACE_USING_DIRECTIVE

TF_WRAP_MODULE
{
TF_WRAP(CapsuleMeshGenerator);
TF_WRAP(ConeMeshGenerator);
TF_WRAP(CuboidMeshGenerator);
TF_WRAP(CylinderMeshGenerator);
TF_WRAP(SphereMeshGenerator);
TF_WRAP(CapsuleMeshGenerator);
TF_WRAP(ConeMeshGenerator);
TF_WRAP(CuboidMeshGenerator);
TF_WRAP(CylinderMeshGenerator);
TF_WRAP(SphereMeshGenerator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,25 @@
//
////////////////////////////////////////////////////////////////////////

#include "pxr/pxr.h"
#include "pxr/base/tf/registryManager.h"
#include "pxr/base/tf/scriptModuleLoader.h"
#include "pxr/base/tf/token.h"
#include "pxr/pxrns.h"
#include "Tf/registryManager.h"
#include "Tf/scriptModuleLoader.h"
#include "Tf/token.h"

#include <vector>

PXR_NAMESPACE_OPEN_SCOPE

TF_REGISTRY_FUNCTION(TfScriptModuleLoader) {
// List of direct dependencies for this library.
const std::vector<TfToken> reqs = {
TfToken("arch"),
TfToken("gf"),
TfToken("pxOsd"),
TfToken("tf"),
TfToken("vt")
};
TfScriptModuleLoader::GetInstance().
RegisterLibrary(TfToken("geomUtil"), TfToken("pxr.GeomUtil"), reqs);
TF_REGISTRY_FUNCTION(TfScriptModuleLoader)
{
// List of direct dependencies for this library.
const std::vector<TfToken> reqs = {
TfToken("arch"),
TfToken("gf"),
TfToken("pxOsd"),
TfToken("tf"),
TfToken("vt")};
TfScriptModuleLoader::GetInstance().RegisterLibrary(TfToken("geomUtil"), TfToken("pxr.GeomUtil"), reqs);
}

PXR_NAMESPACE_CLOSE_SCOPE


Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/imaging/geomUtil/capsuleMeshGenerator.h"
#include "GeomUtil/capsuleMeshGenerator.h"

#include "pxr/imaging/pxOsd/meshTopology.h"
#include "PxOsd/meshTopology.h"

#include "pxr/base/vt/types.h"
#include "Vt/types.h"

#include <boost/python/class.hpp>

Expand All @@ -40,40 +40,40 @@ _WrapGeneratePoints(
const float radius,
const float height)
{
const size_t numPoints =
GeomUtilCapsuleMeshGenerator::ComputeNumPoints(numRadial, numCapAxial);
if (numPoints == 0) {
return VtVec3fArray();
}
const size_t numPoints =
GeomUtilCapsuleMeshGenerator::ComputeNumPoints(numRadial, numCapAxial);
if (numPoints == 0)
{
return VtVec3fArray();
}

VtVec3fArray points(numPoints);
GeomUtilCapsuleMeshGenerator::GeneratePoints(
points.begin(), numRadial, numCapAxial, radius, height);
VtVec3fArray points(numPoints);
GeomUtilCapsuleMeshGenerator::GeneratePoints(
points.begin(), numRadial, numCapAxial, radius, height);

return points;
return points;
}

void wrapCapsuleMeshGenerator()
{
using This = GeomUtilCapsuleMeshGenerator;
using This = GeomUtilCapsuleMeshGenerator;

// Pull the constexpr values into variables so boost can odr-use them.
static constexpr size_t minNumRadial = This::minNumRadial;
static constexpr size_t minNumCapAxial = This::minNumCapAxial;
// Pull the constexpr values into variables so boost can odr-use them.
static constexpr size_t minNumRadial = This::minNumRadial;
static constexpr size_t minNumCapAxial = This::minNumCapAxial;

// Note: These are only "classes" for name scoping, and are uninstantiable;
// hence no need to bother declaring bases.
class_<This>("CapsuleMeshGenerator", no_init)
.def_readonly("minNumRadial", minNumRadial)
.def_readonly("minNumCapAxial", minNumCapAxial)
// Note: These are only "classes" for name scoping, and are uninstantiable;
// hence no need to bother declaring bases.
class_<This>("CapsuleMeshGenerator", no_init)
.def_readonly("minNumRadial", minNumRadial)
.def_readonly("minNumCapAxial", minNumCapAxial)

.def("ComputeNumPoints", &This::ComputeNumPoints)
.staticmethod("ComputeNumPoints")
.def("ComputeNumPoints", &This::ComputeNumPoints)
.staticmethod("ComputeNumPoints")

.def("GenerateTopology", &This::GenerateTopology)
.staticmethod("GenerateTopology")
.def("GenerateTopology", &This::GenerateTopology)
.staticmethod("GenerateTopology")

.def("GeneratePoints", &_WrapGeneratePoints)
.staticmethod("GeneratePoints")
;
.def("GeneratePoints", &_WrapGeneratePoints)
.staticmethod("GeneratePoints");
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/imaging/geomUtil/coneMeshGenerator.h"
#include "GeomUtil/coneMeshGenerator.h"

#include "pxr/imaging/pxOsd/meshTopology.h"
#include "PxOsd/meshTopology.h"

#include "pxr/base/vt/types.h"
#include "Vt/types.h"

#include <boost/python/class.hpp>

Expand All @@ -39,38 +39,38 @@ _WrapGeneratePoints(
const float radius,
const float height)
{
const size_t numPoints =
GeomUtilConeMeshGenerator::ComputeNumPoints(numRadial);
if (numPoints == 0) {
return VtVec3fArray();
}
const size_t numPoints =
GeomUtilConeMeshGenerator::ComputeNumPoints(numRadial);
if (numPoints == 0)
{
return VtVec3fArray();
}

VtVec3fArray points(numPoints);
GeomUtilConeMeshGenerator::GeneratePoints(
points.begin(), numRadial, radius, height);
VtVec3fArray points(numPoints);
GeomUtilConeMeshGenerator::GeneratePoints(
points.begin(), numRadial, radius, height);

return points;
return points;
}

void wrapConeMeshGenerator()
{
using This = GeomUtilConeMeshGenerator;
using This = GeomUtilConeMeshGenerator;

// Pull the constexpr values into variables so boost can odr-use them.
static constexpr size_t minNumRadial = This::minNumRadial;
// Pull the constexpr values into variables so boost can odr-use them.
static constexpr size_t minNumRadial = This::minNumRadial;

// Note: These are only "classes" for name scoping, and are uninstantiable;
// hence no need to bother declaring bases.
class_<This>("ConeMeshGenerator", no_init)
.def_readonly("minNumRadial", minNumRadial)
// Note: These are only "classes" for name scoping, and are uninstantiable;
// hence no need to bother declaring bases.
class_<This>("ConeMeshGenerator", no_init)
.def_readonly("minNumRadial", minNumRadial)

.def("ComputeNumPoints", &This::ComputeNumPoints)
.staticmethod("ComputeNumPoints")
.def("ComputeNumPoints", &This::ComputeNumPoints)
.staticmethod("ComputeNumPoints")

.def("GenerateTopology", &This::GenerateTopology)
.staticmethod("GenerateTopology")
.def("GenerateTopology", &This::GenerateTopology)
.staticmethod("GenerateTopology")

.def("GeneratePoints", &_WrapGeneratePoints)
.staticmethod("GeneratePoints")
;
.def("GeneratePoints", &_WrapGeneratePoints)
.staticmethod("GeneratePoints");
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/imaging/geomUtil/cuboidMeshGenerator.h"
#include "GeomUtil/cuboidMeshGenerator.h"

#include "pxr/imaging/pxOsd/meshTopology.h"
#include "PxOsd/meshTopology.h"

#include "pxr/base/vt/types.h"
#include "Vt/types.h"

#include <boost/python/class.hpp>

Expand All @@ -39,34 +39,34 @@ _WrapGeneratePoints(
const float yLength,
const float zLength)
{
const size_t numPoints =
GeomUtilCuboidMeshGenerator::ComputeNumPoints();
if (numPoints == 0) {
return VtVec3fArray();
}
const size_t numPoints =
GeomUtilCuboidMeshGenerator::ComputeNumPoints();
if (numPoints == 0)
{
return VtVec3fArray();
}

VtVec3fArray points(numPoints);
GeomUtilCuboidMeshGenerator::GeneratePoints(
points.begin(), xLength, yLength, zLength);
VtVec3fArray points(numPoints);
GeomUtilCuboidMeshGenerator::GeneratePoints(
points.begin(), xLength, yLength, zLength);

return points;
return points;
}

void wrapCuboidMeshGenerator()
{
using This = GeomUtilCuboidMeshGenerator;
using This = GeomUtilCuboidMeshGenerator;

// Note: These are only "classes" for name scoping, and are uninstantiable;
// hence no need to bother declaring bases.
class_<This>("CuboidMeshGenerator", no_init)
// Note: These are only "classes" for name scoping, and are uninstantiable;
// hence no need to bother declaring bases.
class_<This>("CuboidMeshGenerator", no_init)

.def("ComputeNumPoints", &This::ComputeNumPoints)
.staticmethod("ComputeNumPoints")
.def("ComputeNumPoints", &This::ComputeNumPoints)
.staticmethod("ComputeNumPoints")

.def("GenerateTopology", &This::GenerateTopology)
.staticmethod("GenerateTopology")
.def("GenerateTopology", &This::GenerateTopology)
.staticmethod("GenerateTopology")

.def("GeneratePoints", &_WrapGeneratePoints)
.staticmethod("GeneratePoints")
;
.def("GeneratePoints", &_WrapGeneratePoints)
.staticmethod("GeneratePoints");
}
Loading

0 comments on commit 9b6644f

Please sign in to comment.