Go to the documentation of this file.
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
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);
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);
113 GU_Detail
const *
const mGdp;
114 std::vector<openvdb::Vec4I>*
const mPrimList;
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,
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;
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
Convert polygonal meshes that consist of quads and/or triangles into signed or unsigned distance fiel...
OPENVDB_API const Coord COORD_OFFSETS[26]
coordinate offset table for neighboring voxels
Definition: AttributeTransferUtil.h:33
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
TBB body object for threaded sharp feature construction.
Definition: GeometryUtil.h:175
void operator()(const GA_SplittableRange &) const
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...
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:445
Wrapper class that adapts a Houdini UT_Interrupt object for use with OpenVDB library routines.
Definition: openvdb_houdini/openvdb_houdini/Utils.h:174
void operator()(const GA_SplittableRange &) const
OPENVDB_HOUDINI_API std::unique_ptr< GU_Detail > convertGeometry(const GU_Detail &, std::string &warning, Interrupter *)
Convert geometry to quads and triangles.
GenAdaptivityMaskOp(const GU_Detail &refGeo, const IndexTreeType &indexTree, BoolLeafManager &, float edgetolerance=0.0)
Definition: GeometryUtil.h:195
VertexNormalOp(GU_Detail &, const GA_PrimitiveGroup *interiorPrims=nullptr, float angle=0.7f)
void run(bool threaded=true)
Definition: GeometryUtil.h:209
void operator()(const tbb::blocked_range< size_t > &) const
Definition: GeometryUtil.h:221
TBB body object for threaded vertex normal generation.
Definition: GeometryUtil.h:125
openvdb::tools::MeshToVoxelEdgeData EdgeData
Definition: GeometryUtil.h:151
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_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.
openvdb::tree::LeafManager< BoolTreeType > BoolLeafManager
Definition: GeometryUtil.h:177
A LeafManager manages a linear array of pointers to a given tree's leaf nodes, as well as optional au...
void operator()(const GA_SplittableRange &) const
TBB body object for threaded primitive copy.
Definition: GeometryUtil.h:107
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.
TBB body object for threaded sharp feature construction.
Definition: GeometryUtil.h:149
PrimCpyOp(GU_Detail const *const gdp, std::vector< openvdb::Vec4I > &primList)