示例#1
0
//update all the physical model atoms positions
void PMLReader::updatePML()
{
	std::vector<PMLBody*>::iterator itb = bodiesList.begin();
	StructuralComponent * atoms = pm->getAtoms();
	Atom * atom;

	while (itb != bodiesList.end())
	{
		if( (*itb)->isTypeOf() != "interaction" )
		{
			if ((*itb)->isTypeOf() != "rigid" || ((PMLRigidBody*)*itb)->bodyFixed == false)
			{
				std::map<unsigned int, unsigned int>::iterator itm = (*itb)->AtomsToDOFsIndexes.begin();
				while(itm != (*itb)->AtomsToDOFsIndexes.end() )
				{
					atom = (Atom*) atoms->getStructureByIndex( (*itm).first );
					Vector3 pos = (*itb)->getDOF((*itm).second);
					atom->setPosition(pos[0], pos[1], pos[2]);

					itm++;
				}
			}
		}
		itb++;
	}
}
    TextBasedDMFramework *FindTextBasedDMFramework(mxfpp::HeaderMetadata *header_metadata, mxfUL xml_metadata_scheme_id, mxfpp::StaticTrack **static_track) {

        MaterialPackage *mp = header_metadata->getPreface()->findMaterialPackage();

        if (!mp)
            return NULL;

        // expect to find Static DM Track -> Sequence -> DM Segment -> DM Framework (a TextBasedDMFramework)
        std::vector<GenericTrack*> tracks = mp->getTracks();
        size_t i;
        for (i = 0; i < tracks.size(); i++) {
            StaticTrack *st = dynamic_cast<StaticTrack*>(tracks[i]);
            if (!st)
                continue;

            StructuralComponent *sc = st->getSequence();
            if (!sc || sc->getDataDefinition() != MXF_DDEF_L(DescriptiveMetadata))
                continue;

            Sequence *seq = dynamic_cast<Sequence*>(sc);
            DMSegment *seg = dynamic_cast<DMSegment*>(sc);
            if (!seq && !seg)
                continue;

            if (seq) {
                std::vector<StructuralComponent*> scs = seq->getStructuralComponents();
                if (scs.size() != 1)
                    continue;

                seg = dynamic_cast<DMSegment*>(scs[0]);
                if (!seg)
                    continue;
            }

            if (!seg->haveDMFramework())
                continue;

            DMFramework *framework = seg->getDMFrameworkLight();
            if (framework) {

		        TextBasedDMFramework *fw = dynamic_cast<TextBasedDMFramework*>(framework);
                if (!fw)
                    continue;
                TextBasedObject *t = dynamic_cast<TextBasedObject*>(fw->getTextBasedObject());
                if (!t)
                    continue;

                mxfUL ul = t->getTextBasedMetadataPayloadSchemaID();
                if (mxf_equals_ul(&ul, &xml_metadata_scheme_id)) {
                    // this is a match!
                    if (static_track != NULL)
                        *static_track = st;
                    return fw;
                }
            }
        }

        return NULL;
    }
示例#3
0
文件: AvidInfo.cpp 项目: hdsdi3g/bmx
void AvidInfo::GetLocators(MaterialPackage *mp)
{
    // expect to find (DM) Event Track - (DM) Sequence - DMSegment
    vector<GenericTrack*> tracks = mp->getTracks();
    size_t i;
    for (i = 0; i < tracks.size(); i++) {
        EventTrack *et = dynamic_cast<EventTrack*>(tracks[i]);
        if (!et)
            continue;

        StructuralComponent *sc = et->getSequence();
        if (!sc || sc->getDataDefinition() != MXF_DDEF_L(DescriptiveMetadata))
            continue;

        Sequence *seq = dynamic_cast<Sequence*>(sc);
        if (!seq)
            continue;

        vector<StructuralComponent*> dm_segs = seq->getStructuralComponents();
        if (dm_segs.empty())
            continue;

        size_t j;
        for (j = 0; j < dm_segs.size(); j++) {
            DMSegment *seg = dynamic_cast<DMSegment*>(dm_segs[j]);
            if (!seg)
                break;

            AvidLocator locator;
            locator.position = seg->getEventStartPosition();
            if (seg->haveEventComment())
                locator.comment = seg->getEventComment();
            if (seg->haveItem(&MXF_ITEM_K(DMSegment, CommentMarkerColor))) {
                RGBColor rgb_color;
                BMX_CHECK(mxf_avid_get_rgb_color_item(seg->getCMetadataSet(),
                                                      &MXF_ITEM_K(DMSegment, CommentMarkerColor),
                                                      &rgb_color));
                locator.color = convert_rgb_color(&rgb_color);
            } else {
                locator.color = COLOR_BLACK;
            }
            locators.push_back(locator);
        }
        if (j < dm_segs.size())
            locators.clear();

        locators_edit_rate = et->getEventEditRate();
        break;
    }
}
示例#4
0
// ------------------ surface ---------------------
SReal Cell::surface()
{
    if (getProperties()->getType()== StructureProperties::QUAD || getProperties()->getType()== StructureProperties::TRIANGLE)
    {
        SReal A[3]= {0.0, 0.0, 0.0 };
        unsigned int nbElem;

        nbElem = Cell::getNumberOfStructures();

        SReal posi[3], posip1[3];
        ((Atom*)getStructure(0))->getPosition(posip1);

        for (unsigned int i=0; i<nbElem; i++) {
            posi[0]=posip1[0];
            posi[1]=posip1[1];
            posi[2]=posip1[2];
            ((Atom*)getStructure((i+1)%nbElem))->getPosition(posip1);
            //Cross(posi, posip1, inter);
            A[0] += posi[1]*posip1[2] - posi[2]*posip1[1];
            A[1] += posi[2]*posip1[0] - posi[0]*posip1[2];
            A[2] += posi[0]*posip1[1] - posi[1]*posip1[0];
        }

        // here A is in fact twice the theoritical area vector
        A[0] /= 2.0;
        A[1] /= 2.0;
        A[2] /= 2.0;

        // face normal :
        SReal * N = normal();

        SReal surface = N[0]*A[0] + N[1]*A[1] + N[2]*A[2];

        return surface>0?surface:-surface;
    }
    else {
        StructuralComponent * facets = getFacets();
        if (!facets)
            return 0.0;
        SReal surface=0.0;
        for (unsigned int i=0 ; i<facets->getNumberOfCells() ; i++) {
            surface += facets->getCell(i)->surface();
        }
        return surface;
    }
}
mxfRational FindMaterialPackageEditRate(HeaderMetadata *header_metadata) {
	Track *selectedTrack = NULL;
	MaterialPackage *material_package = header_metadata->getPreface()->findMaterialPackage();
	const std::vector<GenericTrack*>& tracks = material_package->getTracks();
	for (std::vector<GenericTrack*>::const_iterator it = tracks.begin(); it!=tracks.end(); it++) {
		// use only regular timeline tracks
		Track *tlTrk = dynamic_cast<Track*>(*it);
		if (tlTrk!=NULL) {
			// find the timeline component of this track
			StructuralComponent *comp = tlTrk->getSequence();
			if (comp->getDataDefinition() == MXF_DDEF_L(Timecode)) {
				// this is it, fetch editrate from the track
				selectedTrack = tlTrk;
				break;
			}
		}
	}
	if (selectedTrack == NULL) {
		for (std::vector<GenericTrack*>::const_iterator it = tracks.begin(); it!=tracks.end(); it++) {
			Track *tlTrk = dynamic_cast<Track*>(*it);
			if (tlTrk!=NULL) {
				if (tlTrk->getSequence()->getDataDefinition() == MXF_DDEF_L(Picture)) {
					selectedTrack = tlTrk;
					break;
				}
			}
		}
	}
	if (selectedTrack == NULL) {
		for (std::vector<GenericTrack*>::const_iterator it = tracks.begin(); it!=tracks.end(); it++) {
			Track *tlTrk = dynamic_cast<Track*>(*it);
			if (tlTrk!=NULL) {
				if (tlTrk->getSequence()->getDataDefinition() == MXF_DDEF_L(Sound)) {
					selectedTrack = tlTrk;
					break;
				}
			}
		}
	}

	mxfRational rate = {-1, 0};
	if (selectedTrack != NULL) rate = selectedTrack->getEditRate();
	return rate;
}
std::vector<DMFramework*> GetStaticFrameworks(MaterialPackage *mp)
{
    std::vector<DMFramework*> frameworks;

    // expect to find Static DM Track -> Sequence -> DM Segment -> DM Framework

    std::vector<GenericTrack*> tracks = mp->getTracks();
    size_t i;
    for (i = 0; i < tracks.size(); i++) {
        StaticTrack *st = dynamic_cast<StaticTrack*>(tracks[i]);
        if (!st)
            continue;

        StructuralComponent *sc = st->getSequence();
        if (!sc || sc->getDataDefinition() != MXF_DDEF_L(DescriptiveMetadata))
            continue;

        Sequence *seq = dynamic_cast<Sequence*>(sc);
        DMSegment *seg = dynamic_cast<DMSegment*>(sc);
        if (!seq && !seg)
            continue;

        if (seq) {
            std::vector<StructuralComponent*> scs = seq->getStructuralComponents();
            if (scs.size() != 1)
                continue;

            seg = dynamic_cast<DMSegment*>(scs[0]);
            if (!seg)
                continue;
        }

        if (!seg->haveDMFramework())
            continue;

        DMFramework *framework = seg->getDMFrameworkLight();
        if (framework)
            frameworks.push_back(framework);
    }

    return frameworks;
}
示例#7
0
// ------------------ volume ---------------------
SReal Cell::volume()
{
    StructuralComponent * facets = getFacets();
    if (!facets || getProperties()->getType()== StructureProperties::QUAD || getProperties()->getType()== StructureProperties::TRIANGLE)
        return 0.0;

    SReal vol=0.0;
    Cell * face;
    for (unsigned int i=0; i < facets->getNumberOfCells(); i++) {
        face = facets->getCell(i);
        SReal pos[3];
        ((Atom*)face->getStructure(0))->getPosition(pos);
        SReal * N = face->normal();
        vol += face->surface()* ( pos[0]*N[0] + pos[1]*N[1] + pos[2]*N[2] );
    }

    vol /= 3.0;
    return vol>0?vol:-vol;

}
示例#8
0
//save the current scene as a pml filename
void PMLReader::saveAsPML(const char * filename)
{
	std::vector<PMLBody*>::iterator itb = bodiesList.begin();
	StructuralComponent * atoms = pm->getAtoms();
	Atom * atom;

	while (itb != bodiesList.end())
	{
		std::map<unsigned int, unsigned int>::iterator itm = (*itb)->AtomsToDOFsIndexes.begin();
		while(itm != (*itb)->AtomsToDOFsIndexes.end() )
		{
			atom = (Atom*) atoms->getStructureByIndex( (*itm).first );
			Vector3 pos = (*itb)->getDOF((*itm).second);
			atom->setPosition(pos[0], pos[1], pos[2]);

			itm++;
		}
		itb++;
	}
	std::ofstream outputFile(filename);
	pm->xmlPrint(outputFile);
	cout<<"fichier sauvegarde"<<endl;
}
示例#9
0
// ------------------ getFacets ---------------------
StructuralComponent * Cell::getFacets() {

    StructuralComponent * facets = new StructuralComponent(getPhysicalModel());
    Cell * face;
    switch (getProperties()->getType())
    {
    case StructureProperties::HEXAHEDRON :
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(0));
        face->addStructure(getStructure(3));
        face->addStructure(getStructure(2));
        face->addStructure(getStructure(1));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(0));
        face->addStructure(getStructure(4));
        face->addStructure(getStructure(7));
        face->addStructure(getStructure(3));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(0));
        face->addStructure(getStructure(1));
        face->addStructure(getStructure(5));
        face->addStructure(getStructure(4));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(3));
        face->addStructure(getStructure(7));
        face->addStructure(getStructure(6));
        face->addStructure(getStructure(2));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(1));
        face->addStructure(getStructure(2));
        face->addStructure(getStructure(6));
        face->addStructure(getStructure(5));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(4));
        face->addStructure(getStructure(5));
        face->addStructure(getStructure(6));
        face->addStructure(getStructure(7));
        facets->addStructure(face);
        return facets;
    case StructureProperties::TETRAHEDRON :
        face = new Cell(getPhysicalModel(), StructureProperties::TRIANGLE);
        face->addStructure(getStructure(0));
        face->addStructure(getStructure(1));
        face->addStructure(getStructure(2));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::TRIANGLE);
        face->addStructure(getStructure(0));
        face->addStructure(getStructure(2));
        face->addStructure(getStructure(3));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::TRIANGLE);
        face->addStructure(getStructure(0));
        face->addStructure(getStructure(3));
        face->addStructure(getStructure(1));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::TRIANGLE);
        face->addStructure(getStructure(2));
        face->addStructure(getStructure(1));
        face->addStructure(getStructure(3));
        facets->addStructure(face);
        return facets;
    case StructureProperties::WEDGE :
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(2));
        face->addStructure(getStructure(5));
        face->addStructure(getStructure(4));
        face->addStructure(getStructure(1));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(0));
        face->addStructure(getStructure(1));
        face->addStructure(getStructure(4));
        face->addStructure(getStructure(3));
        facets->addStructure(face);
        face = new Cell(getPhysicalModel(), StructureProperties::QUAD);
        face->addStructure(getStructure(2));
        face->addStructure(getStructure(0));
        face->addStructure(getStructure(3));
        face->addStructure(getStructure(5));
        facets->addStructure(face);
        return facets;
    case StructureProperties::QUAD :
    case StructureProperties::TRIANGLE :
        facets->addStructure(this);
        return facets;
    default :
        return NULL;
    }

}