LIST_OF_REALS * STEPWrapper::parseListOfReals(const char *in) { LIST_OF_REALS *l = new LIST_OF_REALS; ErrorDescriptor errdesc; RealAggregate *ra = new RealAggregate(); //ra->StrToVal(in, &errdesc, SDAI_Real, instance_list, 0); ra->StrToVal(in, &errdesc, SCHEMA_NAMESPACE::t_parameter_value, instance_list, 0); RealNode *rn = (RealNode *)ra->GetHead(); while (rn != NULL) { l->push_back(rn->value); rn = (RealNode *)rn->NextNode(); } /* EntityNode *sn = (EntityNode *)ra->GetHead(); SDAI_Application_instance *sse; while (sn != NULL) { sse = (SDAI_Application_instance *)sn->node; CartesianPoint *aCP = new CartesianPoint(this, sse->STEPfile_id); if (aCP->Load(this, sse)) { l->push_back(aCP); } else { std::cout << "Error loading Real list." << std::endl; } sn = (EntityNode *)sn->NextNode(); }*/ delete ra; return l; }
bool Direction::Load(STEPWrapper *sw,SDAI_Application_instance *sse) { step=sw; id = sse->STEPfile_id; if ( !GeometricRepresentationItem::Load(step,sse) ) { std::cout << CLASSNAME << ":Error loading base class ::GeometricRepresentationItem." << 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); STEPattribute *attr = step->getAttribute(sse,"direction_ratios"); if (attr != NULL) { STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a); RealNode *rn = (RealNode *)sa->GetHead(); int index = 0; while ( rn != NULL) { direction_ratios[index++] = rn->value; rn = (RealNode *)rn->NextNode(); } } else { std::cout << CLASSNAME << ": error loading 'coordinate' attribute." << std::endl; } return true; }
bool RationalBSplineCurve::Load(STEPWrapper *sw, SDAI_Application_instance *sse) { step = sw; id = sse->STEPfile_id; // load base class attributes if (!BSplineCurve::Load(sw, sse)) { std::cout << CLASSNAME << ":Error loading base class ::BSplineCurve." << 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 (weights_data.empty()) { STEPattribute *attr = step->getAttribute(sse, "weights_data"); if (attr) { STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a); RealNode *rn = (RealNode *)sa->GetHead(); while (rn != NULL) { weights_data.insert(weights_data.end(), rn->value); rn = (RealNode *)rn->NextNode(); } } else { std::cout << CLASSNAME << ": Error loading RationalBSplineCurve(weights_data)." << std::endl; return false; } } return true; }
void XmlRenderer::renderNode(const RealNode& node) { StringBuffer attrs; attrs << "ty='" << xmlEncode(node.type().typeId()) << "'"; if (node.isImaginary()) attrs << " imag='t'"; displayTagAttr("real", StrHelper(attrs.toString()), String() + node.value()); if (fShowNodeType) fReferencedTypes.insert(std::make_pair(node.type().typeId(), node.type())); }
/** * Transform a RealNode to a XML node. * * @param node A settings tree node representing a real node. * @param parent The parent node of the XML document. */ Void XmlSettingsTree::settingsTreeToXml( RealNode& node, TiXmlNode& parent ) { TiXmlElement* element = new TiXmlElement( XMLSETTINGSTREE_REAL_ELEMENT ); TiXmlText* text = new TiXmlText( TextUtils::doubleToString( node.getValue(), 14 ).c_str() ); element->LinkEndChild( text ); parent.LinkEndChild( element ); }
std::shared_ptr<ExpressionNode> DivisionNode::evaluate(Environment* e) { std::shared_ptr<ExpressionNode> left = a->evaluate(e); std::shared_ptr<ExpressionNode> right = b->evaluate(e); ConstantNode* cLeft = dynamic_cast<ConstantNode*>(&*left); ConstantNode* cRight = dynamic_cast<ConstantNode*>(&*right); if (cLeft != 0 && cRight != 0) { IntegerNode* iLeft = dynamic_cast<IntegerNode*>(cLeft); IntegerNode* iRight = dynamic_cast<IntegerNode*>(cRight); RealNode* rLeft = dynamic_cast<RealNode*>(cLeft); RealNode* rRight = dynamic_cast<RealNode*>(cRight); if (iLeft != 0 && iRight != 0) { return shared_from_this(); } if (iLeft != 0 && rRight != 0) { return std::make_shared<RealNode> (iLeft->getValue() / rRight->getValue()); } if (rLeft != 0 && iRight != 0) { return std::make_shared<RealNode> (rLeft->getValue() / iRight->getValue()); } if (rLeft != 0 && rRight != 0) { return std::make_shared<RealNode> (rLeft->getValue() / rRight->getValue()); } return 0; } else { return std::make_shared<DivisionNode>(left, right); } }
std::shared_ptr<ExpressionNode> MultiplicationNode::evaluate(Environment* e) { std::shared_ptr<ExpressionNode> left = a->evaluate(e); std::shared_ptr<ExpressionNode> right = b->evaluate(e); ConstantNode* cLeft = dynamic_cast<ConstantNode*>(&*left); ConstantNode* cRight = dynamic_cast<ConstantNode*>(&*right); if (cLeft != 0 && cRight != 0) { IntegerNode* iLeft = dynamic_cast<IntegerNode*>(cLeft); IntegerNode* iRight = dynamic_cast<IntegerNode*>(cRight); RealNode* rLeft = dynamic_cast<RealNode*>(cLeft); RealNode* rRight = dynamic_cast<RealNode*>(cRight); if (iLeft != 0 && iRight != 0) { return std::make_shared<IntegerNode> (iLeft->getValue() * iRight->getValue()); } if (iLeft != 0 && rRight != 0) { return std::make_shared<RealNode> (iLeft->getValue() * rRight->getValue()); } if (rLeft != 0 && iRight != 0) { return std::make_shared<RealNode> (rLeft->getValue() * iRight->getValue()); } if (rLeft != 0 && rRight != 0) { return std::make_shared<RealNode> (rLeft->getValue() * rRight->getValue()); } return 0; } else { IntegerNode* iLeft = dynamic_cast<IntegerNode*>(cLeft); IntegerNode* iRight = dynamic_cast<IntegerNode*>(cRight); if (iLeft != 0 && iLeft->getValue() == 1) { return right; } if (iLeft != 0 && iLeft->getValue() == 0) { return std::make_shared<IntegerNode>(0); } if (iRight != 0 && iRight->getValue() == 1) { return left; } if (iRight != 0 && iRight->getValue() == 0) { return std::make_shared<IntegerNode>(0); } return std::make_shared<MultiplicationNode>(left, right); } }
bool BSplineSurfaceWithKnots::Load(STEPWrapper *sw,SDAI_Application_instance *sse) { step=sw; id = sse->STEPfile_id; // load base class attributes if ( !BSplineSurface::Load(step,sse) ) { std::cout << CLASSNAME << ":Error loading base class ::BSplineCurve." << 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 (u_multiplicities.empty()) { STEPattribute *attr = step->getAttribute(sse,"u_multiplicities"); if (attr) { STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a); IntNode *in = (IntNode *)sa->GetHead(); while ( in != NULL) { u_multiplicities.push_back(in->value); in = (IntNode *)in->NextNode(); } } else { std::cout << CLASSNAME << ": Error loading BSplineSurfaceWithKnots(u_multiplicities)." << std::endl; return false; } } if (v_multiplicities.empty()) { STEPattribute *attr = step->getAttribute(sse,"v_multiplicities"); if (attr) { STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a); IntNode *in = (IntNode *)sa->GetHead(); while ( in != NULL) { v_multiplicities.push_back(in->value); in = (IntNode *)in->NextNode(); } } else { std::cout << CLASSNAME << ": Error loading BSplineSurfaceWithKnots(v_multiplicities)." << std::endl; return false; } } if (u_knots.empty()) { STEPattribute *attr = step->getAttribute(sse,"u_knots"); if (attr) { STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a); RealNode *rn = (RealNode *)sa->GetHead(); while ( rn != NULL) { u_knots.push_back(rn->value); rn = (RealNode *)rn->NextNode(); } } else { std::cout << CLASSNAME << ": Error loading BSplineSurfaceWithKnots(knots)." << std::endl; return false; } } if (v_knots.empty()) { STEPattribute *attr = step->getAttribute(sse,"v_knots"); if (attr) { STEPaggregate *sa = (STEPaggregate *)(attr->ptr.a); RealNode *rn = (RealNode *)sa->GetHead(); while ( rn != NULL) { v_knots.push_back(rn->value); rn = (RealNode *)rn->NextNode(); } } else { std::cout << CLASSNAME << ": Error loading BSplineSurfaceWithKnots(knots)." << std::endl; return false; } } knot_spec = (Knot_type)step->getEnumAttribute(sse,"knot_spec"); if (knot_spec > Knot_type_unset) knot_spec = Knot_type_unset; return true; }