8#ifndef OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED
9#define OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED
17#include <OBJ/OBJ_Camera.h>
18#include <GU/GU_Detail.h>
19#include <GEO/GEO_Primitive.h>
20#include <UT/UT_Version.h>
28class GA_SplittableRange;
34 #ifdef OPENVDB_HOUDINI_API
35 #undef OPENVDB_HOUDINI_API
36 #define OPENVDB_HOUDINI_API
50 const UT_Vector3* boxColor,
const UT_Vector3* tickColor,
51 bool shaded,
bool drawTicks =
true);
55#if SYS_VERSION_MAJOR_INT >= 21
56openvdb::math::Transform::Ptr
58 const OBJ_CameraParms&,
const UT_Matrix4D&,
59 float offset,
float nearPlaneDist,
float farPlaneDist,
60 float voxelDepthSize = 1.0,
int voxelCountX = 100);
63openvdb::math::Transform::Ptr
65 OP_Node&, OP_Context&, OBJ_Camera&,
66 float offset,
float nearPlaneDist,
float farPlaneDist,
67 float voxelDepthSize = 1.0,
int voxelCountX = 100);
87std::unique_ptr<GU_Detail>
88convertGeometry(
const GU_Detail&, std::string& warning, openvdb::util::NullInterrupter*);
93std::unique_ptr<GU_Detail>
105 const openvdb::math::Transform& transform,
106 std::vector<openvdb::Vec3s>& pointList);
111 GU_Detail
const *
const mGdp;
112 const openvdb::math::Transform& mTransform;
113 std::vector<openvdb::Vec3s>*
const mPointList;
125 PrimCpyOp(GU_Detail
const *
const gdp, std::vector<openvdb::Vec4I>& primList);
129 GU_Detail
const *
const mGdp;
130 std::vector<openvdb::Vec4I>*
const mPrimList;
143 VertexNormalOp(GU_Detail&,
const GA_PrimitiveGroup* interiorPrims=
nullptr,
float angle=0.7f);
147 bool isInteriorPrim(GA_Offset primOffset)
const
149 return mInteriorPrims && mInteriorPrims->containsIndex(
150 mDetail.primitiveIndex(primOffset));
153 const GU_Detail& mDetail;
154 const GA_PrimitiveGroup* mInteriorPrims;
155 GA_RWHandleV3 mNormalHandle;
167 using EdgeData = openvdb::tools::MeshToVoxelEdgeData;
170 const openvdb::math::Transform& xform,
const GA_PrimitiveGroup* surfacePrims =
nullptr,
177 const GU_Detail& mRefGeo;
179 const openvdb::math::Transform& mXForm;
180 const GA_PrimitiveGroup* mSurfacePrims;
189template<
typename IndexTreeType,
typename BoolTreeType>
196 const IndexTreeType& indexTree,
BoolLeafManager&,
float edgetolerance = 0.0);
198 void run(
bool threaded =
true);
200 void operator()(
const tbb::blocked_range<size_t>&)
const;
203 const GU_Detail& mRefGeo;
204 const IndexTreeType& mIndexTree;
206 float mEdgeTolerance;
210template<
typename IndexTreeType,
typename BoolTreeType>
212 const IndexTreeType& indexTree,
BoolLeafManager& leafMgr,
float edgetolerance)
214 , mIndexTree(indexTree)
216 , mEdgeTolerance(edgetolerance)
218 mEdgeTolerance = std::max(0.0f, mEdgeTolerance);
219 mEdgeTolerance = std::min(1.0f, mEdgeTolerance);
223template<
typename IndexTreeType,
typename BoolTreeType>
228 tbb::parallel_for(mLeafs.getRange(), *
this);
230 (*this)(mLeafs.getRange());
235template<
typename IndexTreeType,
typename BoolTreeType>
238 const tbb::blocked_range<size_t>& range)
const
240 using IndexAccessorType =
typename openvdb::tree::ValueAccessor<const IndexTreeType>;
241 IndexAccessorType idxAcc(mIndexTree);
243 UT_Vector3 tmpN, normal;
244 GA_Offset primOffset;
248 typename BoolTreeType::LeafNodeType::ValueOnIter iter;
250 for (
size_t n = range.begin(); n < range.end(); ++n) {
251 iter = mLeafs.leaf(n).beginValueOn();
252 for (; iter; ++iter) {
253 ijk = iter.getCoord();
255 bool edgeVoxel =
false;
257 int idx = idxAcc.getValue(ijk);
259 primOffset = mRefGeo.primitiveOffset(idx);
260 normal = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
262 for (
size_t i = 0; i < 18; ++i) {
263 nijk = ijk + openvdb::util::COORD_OFFSETS[i];
264 if (idxAcc.probeValue(nijk, tmpIdx) && tmpIdx != idx) {
265 primOffset = mRefGeo.primitiveOffset(tmpIdx);
266 tmpN = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
268 if (normal.dot(tmpN) < mEdgeTolerance) {
275 if (!edgeVoxel) iter.setValueOff();
A LeafManager manages a linear array of pointers to a given tree's leaf nodes, as well as optional au...
Convert polygonal meshes that consist of quads and/or triangles into signed or unsigned distance fiel...
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
void run(bool threaded=true)
Definition GeometryUtil.h:225
void operator()(const tbb::blocked_range< size_t > &) const
Definition GeometryUtil.h:237
openvdb::tree::LeafManager< BoolTreeType > BoolLeafManager
Definition GeometryUtil.h:193
GenAdaptivityMaskOp(const GU_Detail &refGeo, const IndexTreeType &indexTree, BoolLeafManager &, float edgetolerance=0.0)
Definition GeometryUtil.h:211
Deprecated wrapper class with the same interface as HoudiniInterrupter, however it does not derive fr...
Definition Utils.h:218
void operator()(const GA_SplittableRange &) const
PrimCpyOp(GU_Detail const *const gdp, std::vector< openvdb::Vec4I > &primList)
void operator()(const GA_SplittableRange &) const
SharpenFeaturesOp(GU_Detail &meshGeo, const GU_Detail &refGeo, EdgeData &edgeData, const openvdb::math::Transform &xform, const GA_PrimitiveGroup *surfacePrims=nullptr, const openvdb::BoolTree *mask=nullptr)
openvdb::tools::MeshToVoxelEdgeData EdgeData
Definition GeometryUtil.h:167
void operator()(const GA_SplittableRange &) const
VertexNormalOp(GU_Detail &, const GA_PrimitiveGroup *interiorPrims=nullptr, float angle=0.7f)
Definition VoxToNanoVDB.h:15
tree::Tree4< bool, 5, 4, 3 >::Type BoolTree
Common tree types.
Definition openvdb.h:53
Definition AttributeTransferUtil.h:34
OPENVDB_HOUDINI_API bool pointInPrimGroup(GA_Offset ptnOffset, GU_Detail &, const GA_PrimitiveGroup &)
Return true if the point at the given offset is referenced by primitives from a certain primitive gro...
OPENVDB_HOUDINI_API void drawFrustum(GU_Detail &, const openvdb::math::Transform &, const UT_Vector3 *boxColor, const UT_Vector3 *tickColor, bool shaded, bool drawTicks=true)
Add geometry to the given detail to indicate the extents of a frustum transform.
OPENVDB_HOUDINI_API std::unique_ptr< GU_Detail > convertGeometry(const GU_Detail &, std::string &warning, openvdb::util::NullInterrupter *)
Convert geometry to quads and triangles.
OPENVDB_HOUDINI_API openvdb::math::Transform::Ptr frustumTransformFromCamera(OP_Node &, OP_Context &, OBJ_Camera &, float offset, float nearPlaneDist, float farPlaneDist, float voxelDepthSize=1.0, int voxelCountX=100)
Construct a frustum transform from a Houdini camera.