示例#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;
}
示例#2
0
int InsertFromFormula( CFormulaNode *pFormulaNode, SelectNode &sn, int fUpCalc )
{
	if( pFormulaNode == NULL ) return -1;

	if( sn.GetNode()->GetType() == NODE_PLANETEXT ) BreakPlaneText( sn, 0 );

	Q_ASSERT( sn.GetNode()->GetType() == NODE_LINE );

	((CLineNode*) sn.GetNode())->InsertChild( sn.GetPosition(), pFormulaNode );

	pFormulaNode->RecalculateSize( fUpCalc );

	return 0;
}
示例#3
0
void
XmlRenderer::renderNode(const SelectNode& node)
{
  displayOpenTag("select");
  displayNode("test", node.test().get());
  displayNode("comp", node.comparator().get());
  for (size_t i = 0; i < node.mappingCount(); i++) {
    if (node.mappingAt(i).fTestValues.empty()) {
      displayNode("alternate", node.mappingAt(i).fConsequent.get());
    }
    else {
      displayOpenTag("map");
      displayOpenTag("values");
      for (size_t j = 0; j < node.mappingAt(i).fTestValues.size(); j++) {
        displayNode(nullptr, node.mappingAt(i).fTestValues[j].get());
      }
      displayCloseTag("values");
      displayNode("cons", node.mappingAt(i).fConsequent.get());
      displayCloseTag("map");
    }
  }
  displayCloseTag("select");
}
示例#4
0
int InsertFromText( CPlaneText *pPlaneText, SelectNode &sn, int fUpCalc )
{
	if( pPlaneText == NULL ) return -1;

	if( sn.GetNode()->GetType() == NODE_PLANETEXT ) BreakPlaneText( sn, 0 );

	Q_ASSERT( sn.GetNode()->GetType() == NODE_LINE );

	CNode *pPrev, *pNext;
	GetPrevNextInLine( sn, pPrev, pNext );

	((CLineNode*) sn.GetNode())->InsertChild( sn.GetPosition(), pPlaneText );

	sn.SetPosition( sn.GetPosition() + 1 );

	GlueText( sn, pPrev, 0 );
	if( pNext != NULL && (pPrev == NULL || pPrev->GetParent()->GetChildIndex( pNext ) != -1) )
		GlueText( sn, pNext->GetPrev(), 0 );

	sn.GetNode()->RecalculateSize( fUpCalc );

	return 0;
}
示例#5
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;
}
示例#6
0
int InsertFromFrame( CFrameNode *pFrameNode, SelectNode &sn, int fUpCalc, SelectInfo *psi )
{
	if( pFrameNode == NULL ) return -1;

	if( pFrameNode->GetChildCount() == 1 )
	{
		Q_ASSERT( pFrameNode->GetFirstChild()->GetType() == NODE_LINE );
		return ::InsertFromLine( (CLineNode*) pFrameNode->GetChild( 0 ), sn, fUpCalc, psi );
	}
	else
	{
		Q_ASSERT( pFrameNode->GetChildCount() > 0 );

		BreakLine( sn, 0 );

		CNode *pPrev = sn.GetNode()->GetPrev();
		CNode *pNext = sn.GetNode();
		Q_ASSERT( pPrev );
		Q_ASSERT( pNext );

		CParentNode *pParentNode = sn.GetNode()->GetParent();

		int fRecalculateFull = (pFrameNode->GetLevel() != pParentNode->GetLevel());
		
		QVector<CNode*> children;
		pFrameNode->RecalculateSizeFull();
		pFrameNode->RemoveOrCopyChildren( children );

		if( psi )
		{
			psi->GetBegin().SetNode( children[ 0 ] );
			psi->GetBegin().SetPosition( 0 );
			psi->GetEnd() = sn;
		}

		pParentNode->InsertChildren( children, 
			pParentNode->GetChildIndex( sn.GetNode() ) );

		if( pNext->GetPrev() == pPrev )
		{
			Q_ASSERT( 0 );
		}
		else
		{
			if( GlueLine( sn, pNext->GetPrev(), 0, NULL ) == 0 )
				if( psi ) 
					psi->GetEnd() = sn;
			if( GlueLine( sn, pPrev, 0, NULL ) == 0 )
				if( psi ) 
					psi->GetBegin() = sn;
		}

		if( fRecalculateFull )
			pParentNode->RecalculateSizeFull();
		else
			pParentNode->RecalculateSize( 0 );

		if( pParentNode->GetParent() )
			pParentNode->GetParent()->RecalculateSize( fUpCalc );
		return 0;
	}
}
示例#7
0
int InsertFromLine( CLineNode *pLineNode, SelectNode &sn, int fUpCalc, SelectInfo *psi )
{
	if( pLineNode == NULL ) return -1;

	if( sn.GetNode()->GetType() == NODE_PLANETEXT ) BreakPlaneText( sn, -1, NULL );

	Q_ASSERT( sn.GetNode()->GetType() == NODE_LINE );
	CLineNode *pLineTo = ((CLineNode*) sn.GetNode());

	CNode *pPrev, *pNext;
	GetPrevNextInLine( sn, pPrev, pNext );

	long nCount = pLineNode->GetChildCount();

	int fRecalculateFull = (pLineNode->GetLevel() != pLineTo->GetLevel());

	QVector<CNode*> children;
	pLineNode->RecalculateSizeFull();
	pLineNode->RemoveOrCopyChildren( children );

	if( psi )  psi->GetBegin() = sn;

	pLineTo->InsertChildren( children, sn.GetPosition() );

	sn.SetPosition( sn.GetPosition() + nCount );
	if( psi )  psi->GetEnd() = sn;

	int nRet = GlueText( sn, pPrev, 1, (psi ? &psi->GetBegin() : NULL));

	if( psi )
	{
		if( nRet == 0 )
		{
			psi->GetBegin() = sn;
		}
		else if( pPrev )
		{
			psi->GetBegin().SetNode( pPrev->GetParent() );
			psi->GetBegin().SetPosition( pPrev->GetParent()->GetChildIndex( pPrev ) + 1 );
		}
	}

	if( pPrev && pPrev->GetParent()->GetChildIndex( pNext ) != -1 )
	{
		nRet = GlueText( sn, pNext->GetPrev(), (nRet == -1), (psi ? &psi->GetEnd() : NULL) );

		if( psi )
		{
			if( nRet == 0 )
			{
				psi->GetEnd() = sn;
			}
			else 
			{
				psi->GetEnd().SetNode( pNext->GetParent() );
				psi->GetEnd().SetPosition( pNext->GetParent()->GetChildIndex( pNext ) );
			}
		}
	}

	if( fRecalculateFull )
		pLineTo->RecalculateSizeFull();
	else
		pLineTo->RecalculateSize( 1 );

	if( pLineTo->GetParent() )
		pLineTo->GetParent()->RecalculateSize( fUpCalc );

	return 0;
}
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;
}
void CLRBracketSelection::notifyNodeOnCreateBracket( const SelectNode& sn, int isLeft )
{
	if( sn.GetNode() != 0 )
		sn.GetNode()->notifyNodeOnCreateBracket( sn.GetPosition(), isLeft );
}
示例#10
0
void CLRBracketSelection::notifyNodeOnRemoveBracket( const SelectNode& sn )
{
	if( sn.GetNode() != NULL && m_rootNode.haveChild( sn.GetNode() ) )
		sn.GetNode()->notifyNodeOnRemoveBracket( sn.GetPosition() );
}