Cortex  10.0.0-a4
FromHoudiniGroupConverter.h
1 //
3 // Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
35 #ifndef IECOREHOUDINI_FROMHOUDINIGROUPCONVERTER_H
36 #define IECOREHOUDINI_FROMHOUDINIGROUPCONVERTER_H
37 
38 #include "IECore/Group.h"
39 
40 #include "IECoreHoudini/TypeIds.h"
41 #include "IECoreHoudini/FromHoudiniGeometryConverter.h"
42 
43 namespace IECoreHoudini
44 {
45 
49 {
50  public :
51 
52  IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromHoudiniGroupConverter, FromHoudiniGroupConverterTypeId, FromHoudiniGeometryConverter );
53 
54  FromHoudiniGroupConverter( const GU_DetailHandle &handle );
55  FromHoudiniGroupConverter( const SOP_Node *sop );
56 
57  virtual ~FromHoudiniGroupConverter();
58 
60  static FromHoudiniGeometryConverter::Convertability canConvert( const GU_Detail *geo );
61 
62  enum GroupingMode
63  {
64  PrimitiveGroup,
65  NameAttribute
66  };
67 
68  protected :
69 
71  virtual IECore::ObjectPtr doConversion( IECore::ConstCompoundObjectPtr operands ) const;
72 
74  virtual IECore::ObjectPtr doDetailConversion( const GU_Detail *geo, const IECore::CompoundObject *operands ) const;
75 
76  private :
77 
78  typedef std::map<unsigned, GA_PrimitiveGroup*> PrimIdGroupMap;
79  typedef PrimIdGroupMap::value_type PrimIdGroupPair;
80  typedef PrimIdGroupMap::iterator PrimIdGroupMapIterator;
81 
82  typedef std::pair<std::string, unsigned> AttributePrimIdPair;
83  typedef std::map<AttributePrimIdPair, GA_PrimitiveGroup*> AttributePrimIdGroupMap;
84  typedef AttributePrimIdGroupMap::value_type AttributePrimIdGroupPair;
85  typedef AttributePrimIdGroupMap::iterator AttributePrimIdGroupMapIterator;
86 
87  // add parameters needed by both contructors
88  void constructCommon();
89 
91  size_t doGroupConversion( const GU_Detail *geo, GA_PrimitiveGroup *group, IECore::VisibleRenderablePtr &result, const IECore::CompoundObject *operands ) const;
92 
94  void convertAndAddPrimitive( GU_Detail *geo, GA_PrimitiveGroup *group, IECore::GroupPtr &result, const IECore::CompoundObject *operands, const std::string &name = "" ) const;
95 
100  size_t regroup( GU_Detail *geo, PrimIdGroupMap &groupMap ) const;
101 
103  void doUnnamedConversion( const GU_Detail *geo, IECore::Group *result, const IECore::CompoundObject *operands, const std::string &name = "" ) const;
104 
106 };
107 
108 // register our converter
109 IE_CORE_DECLAREPTR( FromHoudiniGroupConverter );
110 
111 }
112 
113 #endif // IECOREHOUDINI_FROMHOUDINIGROUPCONVERTER_H
Definition: FromHoudiniGroupConverter.h:48
Definition: Group.h:53
The IECoreHoudini namespace holds all the functionality of libIECoreHoudini.
Definition: CoreHoudini.h:51
Definition: FromHoudiniGeometryConverter.h:65
const GU_DetailHandle & handle() const
returns a reference to the GU_DetailHandle
Definition: CompoundObject.h:46
Definition: FromHoudiniGeometryConverter.h:123
static FromHoudiniGeometryConverter::Convertability canConvert(const GU_Detail *geo)
Determines if the given GU_Detail can be converted.
virtual IECore::ObjectPtr doConversion(IECore::ConstCompoundObjectPtr operands) const
Re-implemented to perform conversion to an IECore::Group.
virtual IECore::ObjectPtr doDetailConversion(const GU_Detail *geo, const IECore::CompoundObject *operands) const
Uses the factory mechanism to find the best converter for the given GU_Detail.