8 #ifndef OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED 9 #define OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED 17 #include <OBJ/OBJ_Camera.h> 18 #include <GU/GU_Detail.h> 19 #include <GEO/GEO_Primitive.h> 20 #include <UT/UT_Version.h> 28 class GA_SplittableRange;
34 #ifdef OPENVDB_HOUDINI_API 35 #undef OPENVDB_HOUDINI_API 36 #define OPENVDB_HOUDINI_API 49 drawFrustum(GU_Detail&,
const openvdb::math::Transform&,
50 const UT_Vector3* boxColor,
const UT_Vector3* tickColor,
51 bool shaded,
bool drawTicks =
true);
55 #if SYS_VERSION_MAJOR_INT >= 21 56 openvdb::math::Transform::Ptr
58 const OBJ_CameraParms&,
const UT_Matrix4D&,
59 float offset,
float nearPlaneDist,
float farPlaneDist,
60 float voxelDepthSize = 1.0,
int voxelCountX = 100);
63 openvdb::math::Transform::Ptr
65 OP_Node&, OP_Context&, OBJ_Camera&,
66 float offset,
float nearPlaneDist,
float farPlaneDist,
67 float voxelDepthSize = 1.0,
int voxelCountX = 100);
87 std::unique_ptr<GU_Detail>
88 convertGeometry(
const GU_Detail&, std::string& warning, openvdb::util::NullInterrupter*);
93 std::unique_ptr<GU_Detail>
104 TransformOp(GU_Detail
const *
const gdp,
105 const openvdb::math::Transform& transform,
106 std::vector<openvdb::Vec3s>& pointList);
108 void operator()(
const GA_SplittableRange&)
const;
111 GU_Detail
const *
const mGdp;
112 const openvdb::math::Transform& mTransform;
113 std::vector<openvdb::Vec3s>*
const mPointList;
125 PrimCpyOp(GU_Detail
const *
const gdp, std::vector<openvdb::Vec4I>& primList);
126 void operator()(
const GA_SplittableRange&)
const;
129 GU_Detail
const *
const mGdp;
130 std::vector<openvdb::Vec4I>*
const mPrimList;
143 VertexNormalOp(GU_Detail&,
const GA_PrimitiveGroup* interiorPrims=
nullptr,
float angle=0.7f);
144 void operator()(
const GA_SplittableRange&)
const;
147 bool isInteriorPrim(GA_Offset primOffset)
const 149 return mInteriorPrims && mInteriorPrims->containsIndex(
150 mDetail.primitiveIndex(primOffset));
153 const GU_Detail& mDetail;
154 const GA_PrimitiveGroup* mInteriorPrims;
155 GA_RWHandleV3 mNormalHandle;
167 using EdgeData = openvdb::tools::MeshToVoxelEdgeData;
170 const openvdb::math::Transform& xform,
const GA_PrimitiveGroup* surfacePrims =
nullptr,
173 void operator()(
const GA_SplittableRange&)
const;
177 const GU_Detail& mRefGeo;
179 const openvdb::math::Transform& mXForm;
180 const GA_PrimitiveGroup* mSurfacePrims;
189 template<
typename IndexTreeType,
typename BoolTreeType>
196 const IndexTreeType& indexTree,
BoolLeafManager&,
float edgetolerance = 0.0);
200 void operator()(
const tbb::blocked_range<size_t>&)
const;
203 const GU_Detail& mRefGeo;
204 const IndexTreeType& mIndexTree;
206 float mEdgeTolerance;
210 template<
typename IndexTreeType,
typename BoolTreeType>
212 const IndexTreeType& indexTree,
BoolLeafManager& leafMgr,
float edgetolerance)
214 , mIndexTree(indexTree)
216 , mEdgeTolerance(edgetolerance)
218 mEdgeTolerance =
std::max(0.0f, mEdgeTolerance);
219 mEdgeTolerance =
std::min(1.0f, mEdgeTolerance);
223 template<
typename IndexTreeType,
typename BoolTreeType>
228 tbb::parallel_for(mLeafs.getRange(), *
this);
230 (*this)(mLeafs.getRange());
235 template<
typename IndexTreeType,
typename BoolTreeType>
238 const tbb::blocked_range<size_t>& range)
const 240 using IndexAccessorType =
typename openvdb::tree::ValueAccessor<const IndexTreeType>;
241 IndexAccessorType idxAcc(mIndexTree);
243 UT_Vector3 tmpN, normal;
244 GA_Offset primOffset;
247 openvdb::Coord ijk, nijk;
248 typename BoolTreeType::LeafNodeType::ValueOnIter iter;
250 for (
size_t n = range.begin(); n < range.end(); ++n) {
251 iter = mLeafs.leaf(n).beginValueOn();
252 for (; iter; ++iter) {
253 ijk = iter.getCoord();
255 bool edgeVoxel =
false;
257 int idx = idxAcc.getValue(ijk);
259 primOffset = mRefGeo.primitiveOffset(idx);
260 normal = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
262 for (
size_t i = 0; i < 18; ++i) {
264 if (idxAcc.probeValue(nijk, tmpIdx) && tmpIdx != idx) {
265 primOffset = mRefGeo.primitiveOffset(tmpIdx);
266 tmpN = mRefGeo.getGEOPrimitive(primOffset)->computeNormal();
268 if (normal.dot(tmpN) < mEdgeTolerance) {
275 if (!edgeVoxel) iter.setValueOff();
287 #endif // OPENVDB_HOUDINI_GEOMETRY_UTIL_HAS_BEEN_INCLUDED TBB body object for threaded primitive copy.
Definition: GeometryUtil.h:122
TBB body object for threaded vertex normal generation.
Definition: GeometryUtil.h:140
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_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.
void run(bool threaded=true)
Definition: GeometryUtil.h:225
GenAdaptivityMaskOp(const GU_Detail &refGeo, const IndexTreeType &indexTree, BoolLeafManager &, float edgetolerance=0.0)
Definition: GeometryUtil.h:211
TBB body object for threaded sharp feature construction.
Definition: GeometryUtil.h:164
TBB body object for threaded sharp feature construction.
Definition: GeometryUtil.h:190
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...
constexpr Coord COORD_OFFSETS[26]
coordinate offset table for neighboring voxels
Definition: Util.h:22
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:446
Definition: AttributeTransferUtil.h:34
openvdb::tools::MeshToVoxelEdgeData EdgeData
Definition: GeometryUtil.h:167
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:193
void operator()(const tbb::blocked_range< size_t > &) const
Definition: GeometryUtil.h:237