Example #1
0
LIST_OF_ENTITIES *
STEPWrapper::getListOfEntities(SDAI_Application_instance *sse, const char *name)
{
    LIST_OF_ENTITIES *l = new LIST_OF_ENTITIES;

    sse->ResetAttributes();

    STEPattribute *attr;
    while ((attr = sse->NextAttribute()) != NULL) {
	std::string attrval;
	std::string attrname = attr->Name();

	if (attrname.compare(name) == 0) {
	    STEPaggregate *sa = (STEPaggregate *)attr->ptr.a;

	    EntityNode *sn = (EntityNode *)sa->GetHead();
	    SDAI_Application_instance *se;
	    while (sn != NULL) {
		se = (SDAI_Application_instance *)sn->node;

		l->push_back(se);
		sn = (EntityNode *)sn->NextNode();
	    }
	    break;
	}
    }

    return l;
}
bool
CurveBoundedSurface::Load(STEPWrapper *sw, SDAI_Application_instance *sse)
{

    step = sw;
    id = sse->STEPfile_id;

    if (!BoundedSurface::Load(step, sse)) {
	std::cout << CLASSNAME << ":Error loading base class ::BoundedSurface." << std::endl;
	sw->entity_status[id] = STEP_LOAD_ERROR;
	return false;
    }

    // need to do this for local attributes to makes sure we have
    // the actual entity and not a complex/supertype parent
    sse = step->getEntity(sse, ENTITYNAME);

    if (basis_surface == NULL) {
	SDAI_Application_instance *entity = step->getEntityAttribute(sse, "basis_surface");
	if (entity) {
	    basis_surface = dynamic_cast<Surface *>(Factory::CreateObject(sw, entity));
	} else {
	    std::cerr << CLASSNAME << ": error loading 'basis_surface' attribute." << std::endl;
	    sw->entity_status[id] = STEP_LOAD_ERROR;
	    return false;
	}
    }

    if (boundaries.empty()) {
	LIST_OF_ENTITIES *l = step->getListOfEntities(sse, "boundaries");
	LIST_OF_ENTITIES::iterator i;
	for (i = l->begin(); i != l->end(); i++) {
	    SDAI_Application_instance *entity = (*i);
	    if (entity) {
		BoundaryCurve *aAF = dynamic_cast<BoundaryCurve *>(Factory::CreateObject(sw, entity));

		boundaries.push_back(aAF);
	    } else {
		std::cerr << CLASSNAME  << ": Unhandled entity in attribute 'cfs_faces'." << std::endl;
		l->clear();
		sw->entity_status[id] = STEP_LOAD_ERROR;
		delete l;
		return false;
	    }
	}
	l->clear();
	delete l;
    }

    implicit_outer = step->getBooleanAttribute(sse, "implicit_outer");

    sw->entity_status[id] = STEP_LOADED;

    return true;
}
bool
DerivedUnit::Load(STEPWrapper *sw, SDAI_Application_instance *sse)
{
    step = sw;
    id = sse->STEPfile_id;

    if (!Unit::Load(step, sse)) {
	std::cout << CLASSNAME << ":Error loading base class ::Unit." << std::endl;
	sw->entity_status[id] = STEP_LOAD_ERROR;
	return false;
    }

    // need to do this for local attributes to makes sure we have
    // the actual entity and not a complex/supertype parent
    sse = step->getEntity(sse, ENTITYNAME);

    if (elements.empty()) {
	LIST_OF_ENTITIES *l = step->getListOfEntities(sse, "elements");
	LIST_OF_ENTITIES::iterator i;
	for (i = l->begin(); i != l->end(); i++) {
	    DerivedUnitElement *aDUE = dynamic_cast<DerivedUnitElement *>(Factory::CreateObject(sw, (*i)));

	    elements.push_back(aDUE);
	    if (!aDUE->Load(step, (*i))) {
		l->clear();
		sw->entity_status[id] = STEP_LOAD_ERROR;
		delete l;
		return false;
	    }
	}
	l->clear();
	delete l;
    }

    sw->entity_status[id] = STEP_LOADED;

    return true;
}
Example #4
0
bool
ConnectedFaceSet::Load(STEPWrapper *sw, SDAI_Application_instance *sse)
{
    step = sw;
    id = sse->STEPfile_id;

    if (!TopologicalRepresentationItem::Load(step, sse)) {
	std::cout << CLASSNAME << ":Error loading base class ::TopologicalRepresentationItem." << std::endl;
	return false;
    }

    // need to do this for local attributes to makes sure we have
    // the actual entity and not a complex/supertype parent
    sse = step->getEntity(sse, ENTITYNAME);

    if (cfs_faces.empty()) {
	LIST_OF_ENTITIES *l = step->getListOfEntities(sse, "cfs_faces");
	LIST_OF_ENTITIES::iterator i;
	for (i = l->begin(); i != l->end(); i++) {
	    SDAI_Application_instance *entity = (*i);
	    if (entity) {
		Face *aAF = dynamic_cast<Face *>(Factory::CreateObject(sw, entity)); //CreateSurfaceObject(sw,entity));

		cfs_faces.push_back(aAF);
	    } else {
		std::cerr << CLASSNAME  << ": Unhandled entity in attribute 'cfs_faces'." << std::endl;
		l->clear();
		delete l;
		return false;
	    }
	}
	l->clear();
	delete l;
    }

    return true;
}
bool ProductRelatedProductCategory::Load(STEPWrapper *sw, SDAI_Application_instance *sse)
{
    step = sw;
    id = sse->STEPfile_id;

    if (!ProductCategory::Load(step, sse)) {
	std::cout << CLASSNAME << ":Error loading base class ::ProductCategory." << std::endl;
	return false;
    }

    // need to do this for local attributes to makes sure we have
    // the actual entity and not a complex/supertype parent
    sse = step->getEntity(sse, ENTITYNAME);

    if (products.empty()) {
	LIST_OF_ENTITIES *l = step->getListOfEntities(sse, "products");
	LIST_OF_ENTITIES::iterator i;
	for (i = l->begin(); i != l->end(); i++) {
	    SDAI_Application_instance *entity = (*i);
	    if (entity) {
		Product *aProd = dynamic_cast<Product *>(Factory::CreateObject(sw, entity));

		products.push_back(aProd);
	    } else {
		std::cerr << CLASSNAME << ": Unhandled entity in attribute 'products'." << std::endl;
		l->clear();
		delete l;
		return false;
	    }
	}
	l->clear();
	delete l;
    }

    return true;
}
bool
Face::Load(STEPWrapper *sw, SDAI_Application_instance *sse)
{
    step = sw;
    id = sse->STEPfile_id;

    // load base class attributes
    if (!TopologicalRepresentationItem::Load(step, sse)) {
	std::cout << CLASSNAME << ":Error loading base class ::TopologicalRepresentationItem." << std::endl;
	sw->entity_status[id] = STEP_LOAD_ERROR;
	return false;
    }

    // need to do this for local attributes to makes sure we have
    // the actual entity and not a complex/supertype parent
    sse = step->getEntity(sse, ENTITYNAME);

    if (bounds.empty()) {
	LIST_OF_ENTITIES *l = step->getListOfEntities(sse, "bounds");
	LIST_OF_ENTITIES::iterator i;
	for (i = l->begin(); i != l->end(); i++) {
	    SDAI_Application_instance *entity = (*i);
	    if (entity) {
		FaceBound *aFB = dynamic_cast<FaceBound *>(Factory::CreateObject(sw, entity));
		if (aFB) {
		    bounds.push_back(aFB);
		} else {
		    l->clear();
		    sw->entity_status[id] = STEP_LOAD_ERROR;
		    delete l;
		    return false;
		}
	    } else {
		std::cerr << CLASSNAME  << ": Unhandled entity in attribute 'bounds'." << std::endl;
		l->clear();
		sw->entity_status[id] = STEP_LOAD_ERROR;
		delete l;
		return false;
	    }
	}
	l->clear();
	delete l;
    }
    sw->entity_status[id] = STEP_LOADED;
    return true;
}
Example #7
0
bool Representation::Load(STEPWrapper *sw, SDAI_Application_instance *sse)
{
    step = sw;
    id = sse->STEPfile_id;

    // need to do this for local attributes to makes sure we have
    // the actual entity and not a complex/supertype parent
    sse = step->getEntity(sse, ENTITYNAME);

    name = step->getStringAttribute(sse, "name");

    if (items.empty()) {
	LIST_OF_ENTITIES *l = step->getListOfEntities(sse, "items");
	LIST_OF_ENTITIES::iterator i;
	for (i = l->begin(); i != l->end(); i++) {
	    SDAI_Application_instance *entity = (*i);
	    if (entity) {
		RepresentationItem *aRI = dynamic_cast<RepresentationItem *>(Factory::CreateObject(sw, entity));
		if (aRI != NULL)
		    items.push_back(aRI);
	    } else {
		std::cerr << CLASSNAME << ": Unhandled entity in attribute 'items'." << std::endl;
		l->clear();
		delete l;
		return false;
	    }
	}
	l->clear();
	delete l;
    }

    if (context_of_items.empty()) {
	SDAI_Application_instance *entity = step->getEntityAttribute(sse, "context_of_items");
	if (entity) {
	    if (entity->IsComplex()) {
		SDAI_Application_instance *sub_entity = step->getEntity(entity, "Geometric_Representation_Context");
		if (sub_entity) {
		    GeometricRepresentationContext *aGRC = new GeometricRepresentationContext();

		    context_of_items.push_back(aGRC);
		    if (!aGRC->Load(step, sub_entity)) {
			std::cout << CLASSNAME << ":Error loading GeometricRepresentationContext" << std::endl;
			return false;
		    }
		}

		sub_entity = step->getEntity(entity, "Global_Uncertainty_Assigned_Context");
		if (sub_entity) {
		    GlobalUncertaintyAssignedContext *aGUAC = new GlobalUncertaintyAssignedContext();

		    context_of_items.push_back(aGUAC);
		    if (!aGUAC->Load(step, sub_entity)) {
			std::cout << CLASSNAME << ":Error loading GlobalUncertaintyAssignedContext" << std::endl;
			return false;
		    }
		}

		sub_entity = step->getEntity(entity, "Global_Unit_Assigned_Context");
		if (sub_entity) {
		    GlobalUnitAssignedContext *aGUAC = new GlobalUnitAssignedContext();

		    context_of_items.push_back(aGUAC);
		    if (!aGUAC->Load(step, sub_entity)) {
			std::cout << CLASSNAME << ":Error loading GlobalUnitAssignedContext" << std::endl;
			return false;
		    }
		}

		sub_entity = step->getEntity(entity, "Parametric_Representation_Context");
		if (sub_entity) {
		    ParametricRepresentationContext *aPRC = new ParametricRepresentationContext();

		    context_of_items.push_back(aPRC);
		    if (!aPRC->Load(step, sub_entity)) {
			std::cout << CLASSNAME << ":Error loading ParametricRepresentationContext" << std::endl;
			return false;
		    }
		}
	    } else {
		RepresentationContext *aRC = dynamic_cast<RepresentationContext *>(Factory::CreateObject(sw, entity));
		if (aRC != NULL) {
		    context_of_items.push_back(aRC);
		} else {
		    std::cout << CLASSNAME << ":Error loading RepresentationContext" << std::endl;
		    return false;
		}
	    }
	} else {
	    std::cout << CLASSNAME << ":Error loading \"context_of_items\"" << std::endl;
	    return false;
	}
    }
    return true;
}