43 #ifdef TIMING_BUILDBLOCK
48 #define TIMING_LOG(msg) \
49 printf(msg ": %f milliseconds\n", 1000*timer.stop()); \
54 #define TIMING_LOG(msg)
57 using namespace UT::Literal;
59 namespace HDK_Sample {
61 template<
typename INT_T>
64 const std::pair<int,exint> *primtype_count_pairs,
68 const INT_T *vertexpointnumbers,
69 const bool hassharedpoints,
70 const exint *closed_span_lengths,
84 UT_ASSERT(vertexpointnumbers !=
nullptr || npoints_per_copy == nvertices || nvertices == 0);
94 return init_startprim;
103 auto &&functor = [init_startvtx,nvertices,init_startpt,npoints_per_copy,
104 vertexToPoint,pointToVertex,vertexToNext,vertexToPrev,
107 GA_Offset startvtx = init_startvtx +
r.begin()*nvertices;
108 GA_Offset startpt = init_startpt +
r.begin()*npoints_per_copy;
109 for (
exint copyi =
r.begin(), endcopyi =
r.end(); copyi < endcopyi; ++copyi, startvtx += nvertices, startpt += npoints_per_copy)
111 const GA_Offset endvtx = startvtx + nvertices;
112 const GA_Offset endpt = startpt + npoints_per_copy;
120 geo_SetTopoMappedParallel<INT_T>(vertexToPoint, startpt, startvtx, vertexpointnumbers));
127 if (vertexpointnumbers ==
nullptr)
135 geo_SetTopoMappedParallel<INT_T>(pointToVertex, startvtx, startpt,
nullptr));
143 if (!hassharedpoints)
148 pointToVertex->hardenAllPages(startpt, endpt);
150 geo_SetTopoRevMappedParallel<INT_T>(pointToVertex, startpt, startvtx, vertexpointnumbers));
152 TIMING_LOG(
"Setting pt->vtx no shared points");
159 if (pointToVertex && vertexToNext && vertexToPrev)
186 geo_NextPrevParallel<INT_T>(
190 startvtx, startpt, pointToVertex, vertexToPrev, lock));
198 geo_Pt2VtxTopoParallel<INT_T>(pointToVertex, map.
getArray(), map.
size(), vertexpointnumbers, startvtx, startpt));
209 geo_LinkToposParallel<INT_T>(vertexToNext, vertexToPrev, nextvtxarray.
getArray(), prevvtxarray.
getArray(), startvtx));
216 constexpr
exint PARALLEL_THRESHOLD = 4096;
217 if (ncopies >= 2 && ncopies*nvertices >= PARALLEL_THRESHOLD)
221 GA_Offset endvtx = init_startvtx + nvertices*ncopies;
222 GA_Offset endpt = init_startpt + npoints_per_copy*ncopies;
224 vertexToPoint->hardenAllPages(init_startvtx, endvtx);
226 pointToVertex->hardenAllPages(init_startpt, endpt);
227 if (vertexpointnumbers !=
nullptr && hassharedpoints && vertexToNext && vertexToPrev)
229 vertexToNext->hardenAllPages(init_startvtx, endvtx);
230 vertexToPrev->hardenAllPages(init_startvtx, endvtx);
240 return init_startprim;
246 const std::pair<int,exint> *primtype_count_pairs,
248 const GA_Size npoints_per_copy,
250 const int *polygonpointnumbers,
251 const bool hassharedpoints,
252 const exint *closed_span_lengths,
253 const exint ncopies);
256 const std::pair<int,exint> *primtype_count_pairs,
258 const GA_Size npoints_per_copy,
260 const exint *polygonpointnumbers,
261 const bool hassharedpoints,
262 const exint *closed_span_lengths,
263 const exint ncopies);
void UTparallelSort(RandomAccessIterator begin, RandomAccessIterator end, const Compare &compare)
void UTparallelFor(const Range &range, const Body &body, const int subscribe_ratio=2, const int min_grain_size=1, const bool force_use_task_scope=true)
void setSizeNoInit(exint newsize)
template GA_Offset GEObuildPrimitives< exint >(GEO_Detail *detail, const std::pair< int, exint > *primtype_count_pairs, const GA_Offset init_startpt, const GA_Size npoints_per_copy, const GA_PolyCounts &polygonsizelist, const exint *polygonpointnumbers, const bool hassharedpoints, const exint *closed_span_lengths, const exint ncopies)
void setCapacity(exint new_capacity)
void UTparallelForLightItems(const Range &range, const Body &body, const bool force_use_task_scope=true)
GA_Size getNumVertices() const
exint GA_Size
Defines the bit width for index and offset types in GA.
#define GA_INVALID_OFFSET
A range of elements in an index-map.
GA_Size getNumPolygons() const
SYS_FORCE_INLINE const GA_ATITopology * getVertexNextRef() const
GEO_API GA_Offset GEObuildPrimitives(GEO_Detail *detail, const std::pair< int, exint > *primtype_count_pairs, const GA_Offset init_startpt, const GA_Size npoints_per_copy, const GA_PolyCounts &vertexlistsizelist, const INT_T *vertexpointnumbers, const bool hassharedpoints, const exint *closed_span_lengths, const exint ncopies=1)
GA_Topology & getTopology()
SYS_FORCE_INLINE const GA_ATITopology * getVertexPrevRef() const
SYS_FORCE_INLINE const GA_ATITopology * getVertexRef() const
template GA_Offset GEObuildPrimitives< int >(GEO_Detail *detail, const std::pair< int, exint > *primtype_count_pairs, const GA_Offset init_startpt, const GA_Size npoints_per_copy, const GA_PolyCounts &polygonsizelist, const int *polygonpointnumbers, const bool hassharedpoints, const exint *closed_span_lengths, const exint ncopies)
SYS_FORCE_INLINE const GA_ATITopology * getPointRef() const
GA_Offset appendPrimitivesAndVertices(const GA_PrimitiveTypeId &type, GA_Size nprimitives, GA_Size nvertices_each, GA_Offset &vertex_block_start, bool closed_flag=false)