25using Alembic::AbcGeom::FloatArraySamplePtr;
26using Alembic::AbcGeom::kWrapExisting;
27using Alembic::AbcGeom::MetaData;
28using Alembic::AbcGeom::P3fArraySamplePtr;
30using Alembic::AbcGeom::ICompoundProperty;
31using Alembic::AbcGeom::INuPatch;
32using Alembic::AbcGeom::INuPatchSchema;
33using Alembic::AbcGeom::IObject;
46 if (m_schemas.empty()) {
50 std::vector<std::pair<INuPatchSchema, IObject>>::const_iterator it;
51 for (it = m_schemas.begin(); it != m_schemas.end(); ++it) {
52 const INuPatchSchema &schema = it->first;
54 if (!schema.valid()) {
63 const Alembic::AbcCoreAbstract::v12::ObjectHeader &alembic_header,
65 const char **r_err_str)
const
67 if (!Alembic::AbcGeom::INuPatch::matches(alembic_header)) {
69 "Object type mismatch, Alembic object path pointed to NURBS when importing, but not any "
75 *r_err_str =
RPT_(
"Object type mismatch, Alembic object path points to NURBS");
82static bool set_knots(
const FloatArraySamplePtr &knots,
float *&nu_knots)
84 if (!knots || knots->size() < 2) {
89 const size_t num_knots = knots->size() - 2;
90 nu_knots =
static_cast<float *
>(
MEM_callocN(num_knots *
sizeof(
float),
"abc_setsplineknotsu"));
92 for (
size_t i = 0; i < num_knots; i++) {
93 nu_knots[i] = (*knots)[i + 1];
104 std::vector<std::pair<INuPatchSchema, IObject>>::iterator it;
106 for (it = m_schemas.begin(); it != m_schemas.end(); ++it) {
113 const INuPatchSchema &schema = it->first;
114 INuPatchSchema::Sample smp;
116 smp = schema.getValue(sample_sel);
118 catch (Alembic::Util::Exception &ex) {
119 printf(
"Alembic: error reading nurbs sample for '%s/%s' at time %f: %s\n",
121 schema.getName().c_str(),
122 sample_sel.getRequestedTime(),
127 nu->
orderu = smp.getUOrder() - 1;
128 nu->
orderv = smp.getVOrder() - 1;
129 nu->
pntsu = smp.getNumU();
130 nu->
pntsv = smp.getNumV();
134 const P3fArraySamplePtr positions = smp.getPositions();
135 const FloatArraySamplePtr weights = smp.getPositionWeights();
137 const size_t num_points = positions->size();
142 float posw_in = 1.0f;
144 for (
int i = 0; i < num_points; i++, bp++) {
145 const Imath::V3f &pos_in = (*positions)[i];
148 posw_in = (*weights)[i];
152 bp->
vec[3] = posw_in;
170 ICompoundProperty user_props = schema.getUserProperties();
195void AbcNurbsReader::getNurbsPatches(
const IObject &obj)
201 const int num_children = obj.getNumChildren();
203 if (num_children == 0) {
204 INuPatch abc_nurb(obj, kWrapExisting);
205 INuPatchSchema schem = abc_nurb.getSchema();
206 m_schemas.emplace_back(schem, obj);
210 for (
int i = 0; i < num_children; i++) {
212 IObject child(obj, obj.getChildHeader(i).getName());
218 if (!child.valid()) {
222 const MetaData &md = child.getMetaData();
224 if (INuPatch::matches(md) && ok) {
225 INuPatch abc_nurb(child, kWrapExisting);
226 INuPatchSchema schem = abc_nurb.getSchema();
227 m_schemas.emplace_back(schem, child);
230 getNurbsPatches(child);
ListBase * BKE_curve_nurbs_get(Curve *cu)
void BKE_nurb_knot_calc_u(Nurb *nu)
void BKE_nurb_knot_calc_v(Nurb *nu)
Curve * BKE_curve_add(Main *bmain, const char *name, int type)
General operations, lookup, etc. for blender objects.
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override
AbcNurbsReader(const Alembic::Abc::IObject &object, ImportSettings &settings)
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header, const Object *const ob, const char **r_err_str) const override
bool valid() const override
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)