8 #ifndef OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED 9 #define OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED 17 #include <GU/GU_Detail.h> 25 class GA_SplittableRange;
32 #ifdef OPENVDB_HOUDINI_API 33 #undef OPENVDB_HOUDINI_API 34 #define OPENVDB_HOUDINI_API 47 drawFrustum(GU_Detail&,
const openvdb::math::Transform&,
48 const UT_Vector3* boxColor,
const UT_Vector3* tickColor,
49 bool shaded,
bool drawTicks =
true);
54 openvdb::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);
78 std::unique_ptr<GU_Detail>
79 convertGeometry(
const GU_Detail&, std::string& warning, openvdb::util::NullInterrupter*);
84 std::unique_ptr<GU_Detail>
95 TransformOp(GU_Detail
const *
const gdp,
96 const openvdb::math::Transform& transform,
97 std::vector<openvdb::Vec3s>& pointList);
99 void operator()(
const GA_SplittableRange&)
const;
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);
117 void operator()(
const GA_SplittableRange&)
const;
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);
135 void operator()(
const GA_SplittableRange&)
const;
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,
164 void operator()(
const GA_SplittableRange&)
const;
168 const GU_Detail& mRefGeo;
170 const openvdb::math::Transform& mXForm;
171 const GA_PrimitiveGroup* mSurfacePrims;
180 template<
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;
201 template<
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);
214 template<
typename IndexTreeType,
typename BoolTreeType>
219 tbb::parallel_for(mLeafs.getRange(), *
this);
221 (*this)(mLeafs.getRange());
226 template<
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;
238 openvdb::Coord ijk, nijk;
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) {
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();
278 #endif // OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED TBB body object for threaded primitive copy.
Definition: GeometryUtil.h:113
TBB body object for threaded vertex normal generation.
Definition: GeometryUtil.h:131
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.
void run(bool threaded=true)
Definition: GeometryUtil.h:216
GenAdaptivityMaskOp(const GU_Detail &refGeo, const IndexTreeType &indexTree, BoolLeafManager &, float edgetolerance=0.0)
Definition: GeometryUtil.h:202
TBB body object for threaded sharp feature construction.
Definition: GeometryUtil.h:155
OPENVDB_API const Coord COORD_OFFSETS[26]
coordinate offset table for neighboring voxels
TBB body object for threaded sharp feature construction.
Definition: GeometryUtil.h:181
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 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.
Definition: VoxToNanoVDB.h:14
Convert polygonal meshes that consist of quads and/or triangles into signed or unsigned distance fiel...
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:450
Definition: AttributeTransferUtil.h:34
openvdb::tools::MeshToVoxelEdgeData EdgeData
Definition: GeometryUtil.h:158
void run(const char *ax, openvdb::GridBase &grid, const AttributeBindings &bindings={})
Run a full AX pipeline (parse, compile and execute) on a single OpenVDB Grid.
OPENVDB_HOUDINI_API std::unique_ptr< GU_Detail > convertGeometry(const GU_Detail &, std::string &warning, openvdb::util::NullInterrupter *)
Convert geometry to quads and triangles.
A LeafManager manages a linear array of pointers to a given tree's leaf nodes, as well as optional au...
openvdb::tree::LeafManager< BoolTreeType > BoolLeafManager
Definition: GeometryUtil.h:184
void operator()(const tbb::blocked_range< size_t > &) const
Definition: GeometryUtil.h:228