39 #ifndef OPENVDB_TOOLS_LEVELSETSPHERE_HAS_BEEN_INCLUDED 40 #define OPENVDB_TOOLS_LEVELSETSPHERE_HAS_BEEN_INCLUDED 46 #include <boost/utility.hpp> 47 #include <boost/type_traits/is_floating_point.hpp> 68 template<
typename Gr
idType,
typename InterruptT>
69 typename GridType::Ptr
85 template<
typename Gr
idType>
86 typename GridType::Ptr
90 return createLevelSetSphere<GridType, util::NullInterrupter>(radius,center,voxelSize,halfWidth);
103 template<
typename Gr
idT,
typename InterruptT = util::NullInterrupter>
107 typedef typename GridT::ValueType
ValueT;
109 BOOST_STATIC_ASSERT(boost::is_floating_point<ValueT>::value);
122 : mRadius(radius), mCenter(center), mInterrupt(interrupt)
133 mGrid = createLevelSet<GridT>(voxelSize, halfWidth);
134 this->rasterSphere(voxelSize, halfWidth);
140 void rasterSphere(ValueT dx, ValueT w)
146 const ValueT r0 = mRadius/dx, rmax = r0 + w;
149 if (r0 < 1.5f)
return;
152 const Vec3T c(mCenter[0]/dx, mCenter[1]/dx, mCenter[2]/dx);
156 int &
i = ijk[0], &j = ijk[1], &k = ijk[2], m=1;
162 typename GridT::Accessor accessor = mGrid->getAccessor();
164 if (mInterrupt) mInterrupt->start(
"Generating level set of sphere");
166 for (
i = imin;
i <= imax; ++
i ) {
169 for ( j = jmin; j <= jmax; ++j ) {
171 for (k=kmin; k<=kmax; k += m) {
177 accessor.setValue(ijk, dx*v);
188 if (mInterrupt) mInterrupt->end();
191 const ValueT mRadius;
193 InterruptT* mInterrupt;
194 typename GridT::Ptr mGrid;
201 template<
typename Gr
idType,
typename InterruptT>
202 typename GridType::Ptr
204 float halfWidth, InterruptT* interrupt)
207 BOOST_STATIC_ASSERT(boost::is_floating_point<typename GridType::ValueType>::value);
209 typedef typename GridType::ValueType ValueT;
211 return factory.
getLevelSet(ValueT(voxelSize), ValueT(halfWidth));
218 #endif // OPENVDB_TOOLS_LEVELSETSPHERE_HAS_BEEN_INCLUDED
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:101
tbb::atomic< Index32 > i
Definition: LeafBuffer.h:71
int Ceil(float x)
Return the ceiling of x.
Definition: Math.h:806
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:76
#define OPENVDB_VERSION_NAME
Definition: version.h:43
Propagates the sign of distance values from the active voxels in the narrow band to the inactive valu...
Coord Abs(const Coord &xyz)
Definition: Coord.h:509
Definition: Exceptions.h:39
Definition: Exceptions.h:92
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:270
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:48
float Sqrt(float x)
Return the square root of a floating-point value.
Definition: Math.h:711
Type Pow2(Type x)
Return .
Definition: Math.h:498
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
int Floor(float x)
Return the floor of x.
Definition: Math.h:798