Esempio n. 1
0
LIST_OF_SELECTS *
STEPWrapper::getListOfSelects(SDAI_Application_instance *sse, const char *name)
{
    LIST_OF_SELECTS *l = new LIST_OF_SELECTS;
    std::string attrval;

    sse->ResetAttributes();
    STEPattribute *attr;

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

	if (attrname.compare(name) == 0) {

	    SelectAggregate *sa = (SelectAggregate *)attr->ptr.a;
	    SelectNode *sn = (SelectNode *)sa->GetHead();
	    while (sn) {
		l->push_back(sn->node);
		sn = (SelectNode *)sn->NextNode();
	    }
	    break;
	}
    }

    return l;
}
Esempio n. 2
0
bool
SurfaceCurve::Load(STEPWrapper *sw, SDAI_Application_instance *sse)
{
    step = sw;
    id = sse->STEPfile_id;

    if (!Curve::Load(sw, sse)) {
	std::cout << CLASSNAME << ":Error loading base class ::Curve." << 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 (curve_3d == NULL) {
	SDAI_Application_instance *entity = step->getEntityAttribute(sse, "curve_3d");
	if (entity) {
	    curve_3d = dynamic_cast<Curve *>(Factory::CreateObject(sw, entity)); //CreateCurveObject(sw,entity));
	} else {
	    std::cout << CLASSNAME << ":Error loading attribute 'curve_3d'." << std::endl;
	    return false;
	}
    }

    /* TODO: get a sample to work with
       LIST_OF_ENTITIES *l = step->getListOfEntities(sse,"associated_geometry");
       LIST_OF_ENTITIES::iterator i;
       for (i=l->begin();i!=l->end();i++) {
       SDAI_Application_instance *entity = (*i);
       if (entity) {
       PCurveOrSurface *aPCOS = (PCurveOrSurface *)Factory::CreateObject(sw,entity);

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

    if (associated_geometry.empty()) {
	STEPattribute *attr = step->getAttribute(sse, "associated_geometry");
	if (attr) {
	    SelectAggregate *sa = static_cast<SelectAggregate *>(attr->ptr.a);
	    SelectNode *sn = static_cast<SelectNode *>(sa->GetHead());

	    SDAI_Select *p_or_s;
	    while (sn != NULL) {
		p_or_s = static_cast<SDAI_Select *>(sn->node);

		const TypeDescriptor *underlying_type = p_or_s->CurrentUnderlyingType();

		if (underlying_type == SCHEMA_NAMESPACE::e_pcurve ||
		    underlying_type == SCHEMA_NAMESPACE::e_surface)
		{
		    PCurveOrSurface *aPCOS = new PCurveOrSurface();

		    if (!aPCOS->Load(step, p_or_s)) {
			std::cout << CLASSNAME << ":Error loading PCurveOrSurface select." << std::endl;
			delete aPCOS;
			return false;
		    }
		    associated_geometry.push_back(aPCOS);
		} else {
		    std::cout << CLASSNAME << ":Unhandled select in attribute 'associated_geometry': " << p_or_s->CurrentUnderlyingType()->Description() << std::endl;
		    return false;
		}
		sn = static_cast<SelectNode *>(sn->NextNode());
	    }
	}
    }

    master_representation = (Preferred_surface_curve_representation)step->getEnumAttribute(sse, "master_representation");

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

    if (!BoundedCurve::Load(step, sse)) {
	std::cout << CLASSNAME << ":Error loading base class ::BoundedCurve." << std::endl;
	goto step_error;
    }

    // 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_curve == NULL) {
	SDAI_Application_instance *entity = step->getEntityAttribute(sse, "basis_curve");
	if (entity) {
	    basis_curve = dynamic_cast<Curve *>(Factory::CreateObject(sw, entity)); //CreateCurveObject(sw,entity));
	}
	if (!entity || !basis_curve) {
	    std::cerr << CLASSNAME << ": Error loading entity attribute 'basis_curve'." << std::endl;
	    goto step_error;
	}
    }
    if (trim_1.empty()) {
	STEPattribute *attr = step->getAttribute(sse, "trim_1");
	if (attr) {
	    SelectAggregate *sa = static_cast<SelectAggregate *>(attr->ptr.a);
	    if (!sa) goto step_error;
	    SelectNode *sn = static_cast<SelectNode *>(sa->GetHead());
	    SDAI_Select *p;
	    while (sn != NULL) {
		p = static_cast<SDAI_Select *>(sn->node);
		TrimmingSelect *aTS = new TrimmingSelect();

		if (p && !aTS->Load(step, p)) {
		    std::cout << CLASSNAME << ":Error loading TrimmingSelect from list." << std::endl;
		    delete aTS;
		    goto step_error;
		}
		trim_1.push_back(aTS);
		sn = static_cast<SelectNode *>(sn->NextNode());
	    }
	}
    }
    if (trim_2.empty()) {
	STEPattribute *attr = step->getAttribute(sse, "trim_2");
	if (attr) {
	    SelectAggregate *sa = static_cast<SelectAggregate *>(attr->ptr.a);
	    if (!sa) goto step_error;
	    SelectNode *sn = static_cast<SelectNode *>(sa->GetHead());
	    SDAI_Select *p;
	    while (sn != NULL) {
		p = static_cast<SDAI_Select *>(sn->node);
		TrimmingSelect *aTS = new TrimmingSelect();

		if (p && !aTS->Load(step, p)) {
		    std::cout << CLASSNAME << ":Error loading TrimmingSelect from list." << std::endl;
		    delete aTS;
		    goto step_error;
		}
		trim_2.push_back(aTS);
		sn = static_cast<SelectNode *>(sn->NextNode());
	    }
	}
    }

    sense_agreement = step->getBooleanAttribute(sse, "sense_agreement");
    master_representation = (Trimming_preference)step->getEnumAttribute(sse, "master_representation");

    sw->entity_status[id] = STEP_LOADED;
    return true;
step_error:
    sw->entity_status[id] = STEP_LOAD_ERROR;
    return false;
}