37 using Alembic::AbcGeom::FloatArraySamplePtr;
38 using Alembic::AbcGeom::kWrapExisting;
39 using Alembic::AbcGeom::MetaData;
40 using Alembic::AbcGeom::P3fArraySamplePtr;
42 using Alembic::AbcGeom::ICompoundProperty;
43 using Alembic::AbcGeom::INuPatch;
44 using Alembic::AbcGeom::INuPatchSchema;
45 using Alembic::AbcGeom::IObject;
58 if (m_schemas.empty()) {
62 std::vector<std::pair<INuPatchSchema, IObject>>::const_iterator it;
63 for (it = m_schemas.begin(); it != m_schemas.end(); ++it) {
64 const INuPatchSchema &schema = it->first;
66 if (!schema.valid()) {
74 static bool set_knots(
const FloatArraySamplePtr &knots,
float *&nu_knots)
76 if (!knots || knots->size() < 2) {
81 const size_t num_knots = knots->size() - 2;
82 nu_knots =
static_cast<float *
>(
MEM_callocN(num_knots *
sizeof(
float),
"abc_setsplineknotsu"));
84 for (
size_t i = 0; i < num_knots; i++) {
85 nu_knots[i] = (*knots)[i + 1];
96 std::vector<std::pair<INuPatchSchema, IObject>>::iterator it;
98 for (it = m_schemas.begin(); it != m_schemas.end(); ++it) {
105 const INuPatchSchema &schema = it->first;
106 INuPatchSchema::Sample smp;
108 smp = schema.getValue(sample_sel);
110 catch (Alembic::Util::Exception &ex) {
111 printf(
"Alembic: error reading nurbs sample for '%s/%s' at time %f: %s\n",
113 schema.getName().c_str(),
114 sample_sel.getRequestedTime(),
119 nu->
orderu = smp.getUOrder() - 1;
120 nu->
orderv = smp.getVOrder() - 1;
121 nu->
pntsu = smp.getNumU();
122 nu->
pntsv = smp.getNumV();
126 const P3fArraySamplePtr positions = smp.getPositions();
127 const FloatArraySamplePtr weights = smp.getPositionWeights();
129 const size_t num_points = positions->size();
134 float posw_in = 1.0f;
136 for (
int i = 0; i < num_points; i++, bp++) {
137 const Imath::V3f &pos_in = (*positions)[i];
140 posw_in = (*weights)[i];
144 bp->
vec[3] = posw_in;
162 ICompoundProperty user_props = schema.getUserProperties();
189 void AbcNurbsReader::getNurbsPatches(
const IObject &obj)
195 const int num_children = obj.getNumChildren();
197 if (num_children == 0) {
198 INuPatch abc_nurb(obj, kWrapExisting);
199 INuPatchSchema schem = abc_nurb.getSchema();
200 m_schemas.emplace_back(schem, obj);
204 for (
int i = 0; i < num_children; i++) {
206 IObject child(obj, obj.getChildHeader(i).getName());
212 if (!child.valid()) {
216 const MetaData &md = child.getMetaData();
218 if (INuPatch::matches(md) && ok) {
219 INuPatch abc_nurb(child, kWrapExisting);
220 INuPatchSchema schem = abc_nurb.getSchema();
221 m_schemas.emplace_back(schem, child);
224 getNurbsPatches(child);
void BKE_nurb_knot_calc_v(struct Nurb *nu)
struct Curve * BKE_curve_add(struct Main *bmain, const char *name, int type)
void BKE_nurb_knot_calc_u(struct Nurb *nu)
ListBase * BKE_curve_nurbs_get(struct Curve *cu)
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_add_only_object(struct Main *bmain, int type, const char *name) ATTR_NONNULL(1) ATTR_RETURNS_NONNULL
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
AbcNurbsReader(const Alembic::Abc::IObject &object, ImportSettings &settings)
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
std::string m_object_name
Alembic::Abc::IObject m_iobject
void *(* MEM_callocN)(size_t len, const char *str)
bool begins_with(const TContainer &input, const TContainer &match)
void get_min_max_time(const Alembic::AbcGeom::IObject &object, const Schema &schema, chrono_t &min, chrono_t &max)
BLI_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name)
static bool set_knots(const FloatArraySamplePtr &knots, float *&nu_knots)