HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_Mirror.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GEO Library.
7  *
8  * COMMENTS: Geometry mirroring
9  *
10  */
11 #ifndef __GEO_Mirror_h__
12 #define __GEO_Mirror_h__
13 
14 #include "GEO_API.h"
15 
16 #include <GA/GA_IndexMap.h>
17 #include <UT/UT_Array.h>
18 #include <UT/UT_Vector3.h>
19 
20 class GA_PrimitiveGroup;
21 class GEO_Detail;
22 
23 // Provides mapping between mirrored elements and the original source element
25 {
26 public:
27  // Provides mapping between mirrored elements for a particular class:
28  // primitives, points, or vertices
30  {
31  public:
33 
34  // Map GA_Offset of a mirrored element in the destination geometry to
35  // the corresponding item in the source geometry.
37  const GA_IndexMap &dst_map,
38  GA_Offset dst_offset) const
39  {
40  GA_Index src_idx = dst_map.indexFromOffset(dst_offset) - myStart;
41  if (myLookup.entries())
42  src_idx = myLookup(src_idx);
43  return src_map.offsetFromIndex(src_idx);
44  }
45 
46  // Map GA_Offset of a mirrored element in the destination geometry to
47  // the corresponding original item in the destination geometry.
48  // This should only be called if 'keep_original' was specified when
49  // mirroring.
51  const GA_Index base,
52  GA_Offset dst_offset) const
53  {
54  GA_Index src_idx = dst_map.indexFromOffset(dst_offset) - myStart;
55  if (myLookup.entries())
56  src_idx = myLookup(src_idx);
57  return dst_map.offsetFromIndex(base + src_idx);
58  }
59 
60  // GA_Index of the first mirrored component
62  // GA_Index of the last mirrored component + 1
64 
65  // Explicit lookup table used to identify source components if only a
66  // subset of the source geometry was mirrored.
68  };
69 
71 
72  // When isValid() is true, the redirect map can be used to map from
73  // destination elements back to the corresponding source elements
74  bool isValid() const { return myPtBase >= 0; }
75  void setInvalid() { myPtBase = -1; }
76 
77  // Number of points in the destination geometry before mirroring
79  // Number of vertices in the destination geometry before mirroring
81 
85 };
86 
87 // Parameters for the mirror method
89 {
90 public:
91  // Reverse option for primitives that have been mirrored
93  {
94  GEO_MIRROR_NO_REVERSE = 0,
95  GEO_MIRROR_REVERSE = 1,
96  GEO_MIRROR_REVERSE_U = 2,
97  GEO_MIRROR_REVERSE_V = 3
98  };
99 
100  // Constructor
101  GEO_MirrorParms(const GEO_Detail *src_gdp,
102  const GA_PrimitiveGroup *prims_to_mirror,
103  const UT_Vector3R &mirror_normal,
104  const UT_Vector3R &mirror_origin,
105  fpreal dist,
106  bool keep_original,
107  GEO_ReverseOption reverse_direction,
108  bool consolidate_seam,
109  fpreal consolidate_tolerance,
110  bool consolidate_unshared,
111  GEO_MirrorRedirectMap *redirect_map)
112  : mySourceGdp(src_gdp)
113  , myPrimsToMirror(prims_to_mirror)
114  , myMirrorNormal(mirror_normal)
115  , myMirrorOrigin(mirror_origin)
116  , myDist(dist)
117  , myKeepOriginal(keep_original)
118  , myReverseDirection(reverse_direction)
119  , myConsolidateSeam(consolidate_seam)
120  , myConsolidateTolerance(consolidate_tolerance)
121  , myConsolidateUnshared(consolidate_unshared)
122  , myRedirectMap(redirect_map)
123  {
124  }
125 
126  const GEO_Detail *mySourceGdp; // Source gdp
127  const GA_PrimitiveGroup *myPrimsToMirror; // Group belonging to srcgdp
128 
129  UT_Vector3R myMirrorNormal; // must be normalized
137 
138  // When myRedirectMap not null and valid, tells mirror that the geometry
139  // is all in place, all we have to do is move points. The redirect map
140  // will be used to figure out how to map from mirrored element to the
141  // original element. If myRedirect is non-null and invalid then it is
142  // filled with the information you can use next time around.
144 };
145 #endif
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
GA_API const UT_StringHolder dist
UT_Vector3R myMirrorNormal
Definition: GEO_Mirror.h:129
bool myConsolidateSeam
Definition: GEO_Mirror.h:134
ElementRedirect myVertexRedirect
Definition: GEO_Mirror.h:84
UT_Vector3R myMirrorOrigin
Definition: GEO_Mirror.h:130
GEO_MirrorRedirectMap * myRedirectMap
Definition: GEO_Mirror.h:143
SYS_FORCE_INLINE GA_Index indexFromOffset(GA_Offset data_offset) const
Definition: GA_IndexMap.h:145
const GEO_Detail * mySourceGdp
Definition: GEO_Mirror.h:126
GA_Offset getSourceElement(const GA_IndexMap &dst_map, const GA_Index base, GA_Offset dst_offset) const
Definition: GEO_Mirror.h:50
GA_Size GA_Offset
Definition: GA_Types.h:641
GEO_ReverseOption myReverseDirection
Definition: GEO_Mirror.h:133
fpreal myConsolidateTolerance
Definition: GEO_Mirror.h:135
const GA_PrimitiveGroup * myPrimsToMirror
Definition: GEO_Mirror.h:127
#define GEO_API
Definition: GEO_API.h:14
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:635
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:648
GEO_MirrorParms(const GEO_Detail *src_gdp, const GA_PrimitiveGroup *prims_to_mirror, const UT_Vector3R &mirror_normal, const UT_Vector3R &mirror_origin, fpreal dist, bool keep_original, GEO_ReverseOption reverse_direction, bool consolidate_seam, fpreal consolidate_tolerance, bool consolidate_unshared, GEO_MirrorRedirectMap *redirect_map)
Definition: GEO_Mirror.h:101
bool myConsolidateUnshared
Definition: GEO_Mirror.h:136
fpreal64 fpreal
Definition: SYS_Types.h:277
SYS_FORCE_INLINE GA_Offset offsetFromIndex(GA_Index ordered_index) const
Definition: GA_IndexMap.h:117
bool isValid() const
Definition: GEO_Mirror.h:74
GA_Offset getSourceElement(const GA_IndexMap &src_map, const GA_IndexMap &dst_map, GA_Offset dst_offset) const
Definition: GEO_Mirror.h:36
ElementRedirect myPointRedirect
Definition: GEO_Mirror.h:83
ElementRedirect myPrimitiveRedirect
Definition: GEO_Mirror.h:82