HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_BuildPrimitives.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * Declarations of functions for building primitives in bulk.
27  */
28 
29 #pragma once
30 
31 #ifndef __HDK_GEO_BuildPrimitives_h__
32 #define __HDK_GEO_BuildPrimitives_h__
33 
34 #include <GA/GA_PolyCounts.h>
35 #include <GA/GA_Types.h>
36 #include <SYS/SYS_Types.h>
37 #include <utility>
38 
39 class GEO_Detail;
40 
41 namespace HDK_Sample {
42 
43 /// Function for building primitives in bulk, returning the first primitive offset.
44 /// This sets up the primitive list, vertices, and topology attributes,
45 /// parallelizing as much as possible. Any primitive content other than the
46 /// contents of the GA_Primitive base class will be left at default values,
47 /// so other data may still need to be initialized in other ways.
48 ///
49 /// Instantiated for INT_T of int (int32) and exint (int64)
50 ///
51 /// Despiate vertexlistsizelist being a GA_PolyCounts, (a run-length encoded
52 /// array of vertex list sizes), this function works for any primitive types
53 /// specified in the first component of each pair in primtype_count_pairs.
54 ///
55 /// If ncopies > 1, startpt will have npoints_per_copy added to it between each copy.
56 ///
57 /// Values in vertexpointnumbers are offsets, but relative to startpt,
58 /// so if constructing from point offsets, be sure to subtract off startpt
59 /// or specify startpt of GA_Offset(0).
60 ///
61 /// vertexpointnumbers can optionally be nullptr, in which case, vertices will
62 /// be wired to consecutive point offsets. (This implies that there are no
63 /// shared points.) This is a fairly common case for separate curve primitives,
64 /// packed primitives, or polygon soup primitives.
65 ///
66 /// Even if vertexpointnumbers is non-null, hassharedpoints being false can
67 /// save time (if it applies), because not having shared points
68 /// avoids the need to ensure a deterministic order of the linked list
69 /// topology attributes: vertex-to-next-vertex and vertex-to-previous-vertex.
70 ///
71 /// First value of closed_span_lengths is the number with closed false.
72 /// To start with closed true, have a value of 0 first, then the number with closed true.
73 /// nullptr means closed false for all primitives.
74 template<typename INT_T>
76  GEO_Detail *detail,
77  const std::pair<int,exint> *primtype_count_pairs,
78  const GA_Offset init_startpt,
79  const GA_Size npoints_per_copy,
80  const GA_PolyCounts &vertexlistsizelist,
81  const INT_T *vertexpointnumbers,
82  const bool hassharedpoints,
83  const exint *closed_span_lengths,
84  const exint ncopies = 1);
85 
86 } // End of HDK_Sample namespace
87 
88 #endif
int64 exint
Definition: SYS_Types.h:125
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:233
GA_Size GA_Offset
Definition: GA_Types.h:639
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)