8 #ifndef OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED
9 #define OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED
16 #include <GU/GU_Detail.h>
24 class GA_SplittableRange;
31 #ifdef OPENVDB_HOUDINI_API
32 #undef OPENVDB_HOUDINI_API
33 #define OPENVDB_HOUDINI_API
46 drawFrustum(GU_Detail&,
const openvdb::math::Transform&,
47 const UT_Vector3* boxColor,
const UT_Vector3* tickColor,
48 bool shaded,
bool drawTicks =
true);
53 openvdb::math::Transform::Ptr
55 OP_Node&, OP_Context&, OBJ_Camera&,
56 float offset,
float nearPlaneDist,
float farPlaneDist,
57 float voxelDepthSize = 1.0,
int voxelCountX = 100);
77 std::unique_ptr<GU_Detail>
89 const openvdb::math::Transform& transform,
90 std::vector<openvdb::Vec3s>& pointList);
92 void operator()(
const GA_SplittableRange&)
const;
95 GU_Detail
const *
const mGdp;
96 const openvdb::math::Transform& mTransform;
97 std::vector<openvdb::Vec3s>*
const mPointList;
109 PrimCpyOp(GU_Detail
const *
const gdp, std::vector<openvdb::Vec4I>& primList);
110 void operator()(
const GA_SplittableRange&)
const;
113 GU_Detail
const *
const mGdp;
114 std::vector<openvdb::Vec4I>*
const mPrimList;
127 VertexNormalOp(GU_Detail&,
const GA_PrimitiveGroup* interiorPrims=
nullptr,
float angle=0.7f);
128 void operator()(
const GA_SplittableRange&)
const;
131 bool isInteriorPrim(GA_Offset primOffset)
const
133 return mInteriorPrims && mInteriorPrims->containsIndex(
134 mDetail.primitiveIndex(primOffset));
137 const GU_Detail& mDetail;
138 const GA_PrimitiveGroup* mInteriorPrims;
139 GA_RWHandleV3 mNormalHandle;
151 using EdgeData = openvdb::tools::MeshToVoxelEdgeData;
154 const openvdb::math::Transform& xform,
const GA_PrimitiveGroup* surfacePrims =
nullptr,
157 void operator()(
const GA_SplittableRange&)
const;
161 const GU_Detail& mRefGeo;
163 const openvdb::math::Transform& mXForm;
164 const GA_PrimitiveGroup* mSurfacePrims;
173 template<
typename IndexTreeType,
typename BoolTreeType>
180 const IndexTreeType& indexTree,
BoolLeafManager&,
float edgetolerance = 0.0);
182 void run(
bool threaded =
true);
184 void operator()(
const tbb::blocked_range<size_t>&)
const;
187 const GU_Detail& mRefGeo;
188 const IndexTreeType& mIndexTree;
190 float mEdgeTolerance;
194 template<
typename IndexTreeType,
typename BoolTreeType>
196 const IndexTreeType& indexTree,
BoolLeafManager& leafMgr,
float edgetolerance)
198 , mIndexTree(indexTree)
200 , mEdgeTolerance(edgetolerance)
202 mEdgeTolerance =
std::max(0.0f, mEdgeTolerance);
203 mEdgeTolerance =
std::min(1.0f, mEdgeTolerance);
207 template<
typename IndexTreeType,
typename BoolTreeType>
212 tbb::parallel_for(mLeafs.getRange(), *
this);
214 (*this)(mLeafs.getRange());
219 template<
typename IndexTreeType,
typename BoolTreeType>
222 const tbb::blocked_range<size_t>& range)
const
224 using IndexAccessorType =
typename openvdb::tree::ValueAccessor<const IndexTreeType>;
225 IndexAccessorType idxAcc(mIndexTree);
227 UT_Vector3 tmpN, normal;
228 GA_Offset primOffset;
231 openvdb::Coord ijk, nijk;
232 typename BoolTreeType::LeafNodeType::ValueOnIter iter;
234 for (
size_t n = range.begin(); n < range.end(); ++n) {
235 iter = mLeafs.leaf(n).beginValueOn();
236 for (; iter; ++iter) {
237 ijk = iter.getCoord();
239 bool edgeVoxel =
false;
241 int idx = idxAcc.getValue(ijk);
243 primOffset = mRefGeo.primitiveOffset(idx);
244 normal = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
246 for (
size_t i = 0; i < 18; ++i) {
248 if (idxAcc.probeValue(nijk, tmpIdx) && tmpIdx != idx) {
249 primOffset = mRefGeo.primitiveOffset(tmpIdx);
250 tmpN = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
252 if (normal.dot(tmpN) < mEdgeTolerance) {
259 if (!edgeVoxel) iter.setValueOff();
271 #endif // OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED