8#ifndef OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED
9#define OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED
17#include <GU/GU_Detail.h>
25class GA_SplittableRange;
32 #ifdef OPENVDB_HOUDINI_API
33 #undef OPENVDB_HOUDINI_API
34 #define OPENVDB_HOUDINI_API
48 const UT_Vector3* boxColor,
const UT_Vector3* tickColor,
49 bool shaded,
bool drawTicks =
true);
54openvdb::math::Transform::Ptr
56 OP_Node&, OP_Context&, OBJ_Camera&,
57 float offset,
float nearPlaneDist,
float farPlaneDist,
58 float voxelDepthSize = 1.0,
int voxelCountX = 100);
78std::unique_ptr<GU_Detail>
79convertGeometry(
const GU_Detail&, std::string& warning, openvdb::util::NullInterrupter*);
84std::unique_ptr<GU_Detail>
96 const openvdb::math::Transform& transform,
97 std::vector<openvdb::Vec3s>& pointList);
102 GU_Detail
const *
const mGdp;
103 const openvdb::math::Transform& mTransform;
104 std::vector<openvdb::Vec3s>*
const mPointList;
116 PrimCpyOp(GU_Detail
const *
const gdp, std::vector<openvdb::Vec4I>& primList);
120 GU_Detail
const *
const mGdp;
121 std::vector<openvdb::Vec4I>*
const mPrimList;
134 VertexNormalOp(GU_Detail&,
const GA_PrimitiveGroup* interiorPrims=
nullptr,
float angle=0.7f);
138 bool isInteriorPrim(GA_Offset primOffset)
const
140 return mInteriorPrims && mInteriorPrims->containsIndex(
141 mDetail.primitiveIndex(primOffset));
144 const GU_Detail& mDetail;
145 const GA_PrimitiveGroup* mInteriorPrims;
146 GA_RWHandleV3 mNormalHandle;
158 using EdgeData = openvdb::tools::MeshToVoxelEdgeData;
161 const openvdb::math::Transform& xform,
const GA_PrimitiveGroup* surfacePrims =
nullptr,
168 const GU_Detail& mRefGeo;
170 const openvdb::math::Transform& mXForm;
171 const GA_PrimitiveGroup* mSurfacePrims;
180template<
typename IndexTreeType,
typename BoolTreeType>
187 const IndexTreeType& indexTree,
BoolLeafManager&,
float edgetolerance = 0.0);
189 void run(
bool threaded =
true);
191 void operator()(
const tbb::blocked_range<size_t>&)
const;
194 const GU_Detail& mRefGeo;
195 const IndexTreeType& mIndexTree;
197 float mEdgeTolerance;
201template<
typename IndexTreeType,
typename BoolTreeType>
203 const IndexTreeType& indexTree,
BoolLeafManager& leafMgr,
float edgetolerance)
205 , mIndexTree(indexTree)
207 , mEdgeTolerance(edgetolerance)
209 mEdgeTolerance = std::max(0.0f, mEdgeTolerance);
210 mEdgeTolerance = std::min(1.0f, mEdgeTolerance);
214template<
typename IndexTreeType,
typename BoolTreeType>
219 tbb::parallel_for(mLeafs.getRange(), *
this);
221 (*this)(mLeafs.getRange());
226template<
typename IndexTreeType,
typename BoolTreeType>
229 const tbb::blocked_range<size_t>& range)
const
231 using IndexAccessorType =
typename openvdb::tree::ValueAccessor<const IndexTreeType>;
232 IndexAccessorType idxAcc(mIndexTree);
234 UT_Vector3 tmpN, normal;
235 GA_Offset primOffset;
239 typename BoolTreeType::LeafNodeType::ValueOnIter iter;
241 for (
size_t n = range.begin(); n < range.end(); ++n) {
242 iter = mLeafs.leaf(n).beginValueOn();
243 for (; iter; ++iter) {
244 ijk = iter.getCoord();
246 bool edgeVoxel =
false;
248 int idx = idxAcc.getValue(ijk);
250 primOffset = mRefGeo.primitiveOffset(idx);
251 normal = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
253 for (
size_t i = 0; i < 18; ++i) {
254 nijk = ijk + openvdb::util::COORD_OFFSETS[i];
255 if (idxAcc.probeValue(nijk, tmpIdx) && tmpIdx != idx) {
256 primOffset = mRefGeo.primitiveOffset(tmpIdx);
257 tmpN = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
259 if (normal.dot(tmpN) < mEdgeTolerance) {
266 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:25
TBB body object for threaded sharp feature construction.
Definition GeometryUtil.h:182
void run(bool threaded=true)
Definition GeometryUtil.h:216
void operator()(const tbb::blocked_range< size_t > &) const
Definition GeometryUtil.h:228
openvdb::tree::LeafManager< BoolTreeType > BoolLeafManager
Definition GeometryUtil.h:184
GenAdaptivityMaskOp(const GU_Detail &refGeo, const IndexTreeType &indexTree, BoolLeafManager &, float edgetolerance=0.0)
Definition GeometryUtil.h:202
Deprecated wrapper class with the same interface as HoudiniInterrupter, however it does not derive fr...
Definition Utils.h:209
TBB body object for threaded primitive copy.
Definition GeometryUtil.h:114
void operator()(const GA_SplittableRange &) const
PrimCpyOp(GU_Detail const *const gdp, std::vector< openvdb::Vec4I > &primList)
TBB body object for threaded sharp feature construction.
Definition GeometryUtil.h:156
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:158
TBB body object for threaded vertex normal generation.
Definition GeometryUtil.h:132
void operator()(const GA_SplittableRange &) const
VertexNormalOp(GU_Detail &, const GA_PrimitiveGroup *interiorPrims=nullptr, float angle=0.7f)
Definition VoxToNanoVDB.h:15
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.