8 #ifndef OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED 9 #define OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED 17 #include <GU/GU_Detail.h> 18 #include <GEO/GEO_Primitive.h> 26 class GA_SplittableRange;
33 #ifdef OPENVDB_HOUDINI_API 34 #undef OPENVDB_HOUDINI_API 35 #define OPENVDB_HOUDINI_API 48 drawFrustum(GU_Detail&,
const openvdb::math::Transform&,
49 const UT_Vector3* boxColor,
const UT_Vector3* tickColor,
50 bool shaded,
bool drawTicks =
true);
55 openvdb::math::Transform::Ptr
57 OP_Node&, OP_Context&, OBJ_Camera&,
58 float offset,
float nearPlaneDist,
float farPlaneDist,
59 float voxelDepthSize = 1.0,
int voxelCountX = 100);
79 std::unique_ptr<GU_Detail>
80 convertGeometry(
const GU_Detail&, std::string& warning, openvdb::util::NullInterrupter*);
85 std::unique_ptr<GU_Detail>
96 TransformOp(GU_Detail
const *
const gdp,
97 const openvdb::math::Transform& transform,
98 std::vector<openvdb::Vec3s>& pointList);
100 void operator()(
const GA_SplittableRange&)
const;
103 GU_Detail
const *
const mGdp;
104 const openvdb::math::Transform& mTransform;
105 std::vector<openvdb::Vec3s>*
const mPointList;
117 PrimCpyOp(GU_Detail
const *
const gdp, std::vector<openvdb::Vec4I>& primList);
118 void operator()(
const GA_SplittableRange&)
const;
121 GU_Detail
const *
const mGdp;
122 std::vector<openvdb::Vec4I>*
const mPrimList;
135 VertexNormalOp(GU_Detail&,
const GA_PrimitiveGroup* interiorPrims=
nullptr,
float angle=0.7f);
136 void operator()(
const GA_SplittableRange&)
const;
139 bool isInteriorPrim(GA_Offset primOffset)
const 141 return mInteriorPrims && mInteriorPrims->containsIndex(
142 mDetail.primitiveIndex(primOffset));
145 const GU_Detail& mDetail;
146 const GA_PrimitiveGroup* mInteriorPrims;
147 GA_RWHandleV3 mNormalHandle;
159 using EdgeData = openvdb::tools::MeshToVoxelEdgeData;
162 const openvdb::math::Transform& xform,
const GA_PrimitiveGroup* surfacePrims =
nullptr,
165 void operator()(
const GA_SplittableRange&)
const;
169 const GU_Detail& mRefGeo;
171 const openvdb::math::Transform& mXForm;
172 const GA_PrimitiveGroup* mSurfacePrims;
181 template<
typename IndexTreeType,
typename BoolTreeType>
188 const IndexTreeType& indexTree,
BoolLeafManager&,
float edgetolerance = 0.0);
192 void operator()(
const tbb::blocked_range<size_t>&)
const;
195 const GU_Detail& mRefGeo;
196 const IndexTreeType& mIndexTree;
198 float mEdgeTolerance;
202 template<
typename IndexTreeType,
typename BoolTreeType>
204 const IndexTreeType& indexTree,
BoolLeafManager& leafMgr,
float edgetolerance)
206 , mIndexTree(indexTree)
208 , mEdgeTolerance(edgetolerance)
210 mEdgeTolerance =
std::max(0.0f, mEdgeTolerance);
211 mEdgeTolerance =
std::min(1.0f, mEdgeTolerance);
215 template<
typename IndexTreeType,
typename BoolTreeType>
220 tbb::parallel_for(mLeafs.getRange(), *
this);
222 (*this)(mLeafs.getRange());
227 template<
typename IndexTreeType,
typename BoolTreeType>
230 const tbb::blocked_range<size_t>& range)
const 232 using IndexAccessorType =
typename openvdb::tree::ValueAccessor<const IndexTreeType>;
233 IndexAccessorType idxAcc(mIndexTree);
235 UT_Vector3 tmpN, normal;
236 GA_Offset primOffset;
239 openvdb::Coord ijk, nijk;
240 typename BoolTreeType::LeafNodeType::ValueOnIter iter;
242 for (
size_t n = range.begin(); n < range.end(); ++n) {
243 iter = mLeafs.leaf(n).beginValueOn();
244 for (; iter; ++iter) {
245 ijk = iter.getCoord();
247 bool edgeVoxel =
false;
249 int idx = idxAcc.getValue(ijk);
251 primOffset = mRefGeo.primitiveOffset(idx);
252 normal = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
254 for (
size_t i = 0; i < 18; ++i) {
256 if (idxAcc.probeValue(nijk, tmpIdx) && tmpIdx != idx) {
257 primOffset = mRefGeo.primitiveOffset(tmpIdx);
258 tmpN = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
260 if (normal.dot(tmpN) < mEdgeTolerance) {
267 if (!edgeVoxel) iter.setValueOff();
279 #endif // OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED TBB body object for threaded primitive copy.
Definition: GeometryUtil.h:114
TBB body object for threaded vertex normal generation.
Definition: GeometryUtil.h:132
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:217
GenAdaptivityMaskOp(const GU_Detail &refGeo, const IndexTreeType &indexTree, BoolLeafManager &, float edgetolerance=0.0)
Definition: GeometryUtil.h:203
TBB body object for threaded sharp feature construction.
Definition: GeometryUtil.h:156
constexpr Coord COORD_OFFSETS[26]
coordinate offset table for neighboring voxels
Definition: Util.h:22
TBB body object for threaded sharp feature construction.
Definition: GeometryUtil.h:182
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:15
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:446
OPENVDB_AX_API 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.
Definition: AttributeTransferUtil.h:34
openvdb::tools::MeshToVoxelEdgeData EdgeData
Definition: GeometryUtil.h:159
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:185
void operator()(const tbb::blocked_range< size_t > &) const
Definition: GeometryUtil.h:229