Esempio n. 1
0
void SanitiseTool::parseLinkFlankers(xercesc::DOMElement * parentNode, 
                                     crispr::xml::writer& xmlParser)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {

        if (ST_Flank) {
            char * c_flid = tc( currentElement->getAttribute(xmlParser.attr_Flid()));
            std::string flid = c_flid;
            XMLCh * x_new_flid = tc( ST_FlankMap[flid].c_str());
            currentElement->setAttribute(xmlParser.attr_Flid(), x_new_flid);
            xr(&c_flid);
            xr(&x_new_flid);
        }

        if (ST_Repeats) {
            char * c_drid = tc( currentElement->getAttribute(xmlParser.attr_Drid()));
            std::string drid = c_drid;
            XMLCh * x_new_drid = tc(ST_RepeatMap[drid].c_str());
            currentElement->setAttribute(xmlParser.attr_Drid(), x_new_drid);
            xr(&c_drid);
            xr(&x_new_drid);
        }
        
    }
}
Esempio n. 2
0
void StatTool::parseGroup(xercesc::DOMElement * parentNode, 
                          crispr::xml::base& xmlParser)
{
    
    StatManager * sm = new StatManager();
    ST_StatsVec.push_back(sm);
    char * c_cons = tc(parentNode->getAttribute(xmlParser.attr_Drseq()));
    std::string concensusRepeat =c_cons;
    sm->setConcensus(concensusRepeat);
    xr(&c_cons);

    char * c_gid = tc(parentNode->getAttribute(xmlParser.attr_Gid()));
    std::string gid = c_gid;
    xr(&c_gid);
    sm->setGid(gid);
    
    
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {

        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Data())) {
            parseData(currentElement, xmlParser, sm);
        } else if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Metadata())) {
            parseMetadata(currentElement, xmlParser, sm);
        }
    }
}
Esempio n. 3
0
 void
 CachedView<View>::cache(Space& home) {
   _firstRange->dispose(home,_lastRange);
   ViewRanges<View> xr(x);
   _firstRange = new (home) RangeList(xr.min(),xr.max(),NULL);
   ++xr;
   RangeList* cur = _firstRange;
   for (; xr(); ++xr) {
     RangeList* next = new (home) RangeList(xr.min(),xr.max(),NULL);
     cur->next(next);
     cur = next;
   }
   _lastRange = cur;
   _size = x.size();
 }
Esempio n. 4
0
//void DrawTool::parseDrs(xercesc::DOMElement * parentNode, crispr::xml::parser& xmlParser)
//{
//    xercesc::DOMNodeList * children = parentNode->getChildNodes();
//    const  XMLSize_t nodeCount = children->getLength();
//    
//    // For all nodes, children of "root" in the XML tree.
//    for( XMLSize_t xx = 0; xx < nodeCount; ++xx ) {
//        xercesc::DOMNode * currentNode = children->item(xx);
//        if( currentNode->getNodeType() &&  currentNode->getNodeType() == xercesc::DOMNode::ELEMENT_NODE ) {
//            // Found node which is an Element. Re-cast node as element
//            xercesc::DOMElement* currentElement = dynamic_cast< xercesc::DOMElement* >( currentNode );
//            if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.getDr())) {
//
//            }
//        }
//    }
//}
void DrawTool::parseSpacers(xercesc::DOMElement * parentNode, 
                            crispr::xml::parser& xmlParser, 
                            crispr::graph * currentGraph)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {

        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Spacer())) {
            char * node_name = tc(currentElement->getAttribute(xmlParser.attr_Spid()));
            
            Agnode_t * current_graphviz_node = currentGraph->addNode(node_name);
            
            char * shape = strdup("shape");
            char * circle = strdup("circle");
            currentGraph->setNodeAttribute(current_graphviz_node, shape, circle);
            delete shape;
            delete circle;
            
            
            char * c_spid = tc(currentElement->getAttribute(xmlParser.attr_Spid()));
            std::string spid = c_spid;

            if (currentElement->hasAttribute(xmlParser.attr_Cov())) {
                char * c_cov = tc(currentElement->getAttribute(xmlParser.attr_Cov()));
                double current_cov;
                if (from_string<double>(current_cov, c_cov, std::dec)) {
                    recalculateLimits(current_cov);
                    DT_SpacerCoverage[spid] = std::pair<bool, double>(true,current_cov);
                } else {
                    throw crispr::runtime_exception(__FILE__, 
                                                    __LINE__, 
                                                    __PRETTY_FUNCTION__,
                                                    "Unable to convert serialized coverage");
                }
                
                xr(&c_cov);
                
            } else {
                DT_SpacerCoverage[spid] = std::pair<bool, double>(false,0);
            }
            
            xr(&c_spid);
            xr(&node_name);
        }
        
    }
}
Esempio n. 5
0
// Jacobians: dg(b,u)/db, dg(b,u)/du
void linearizeCarDynamics(const Matrix<C_DIM>& c, const Matrix<U_DIM>& u, Matrix<C_DIM,C_DIM>& F, Matrix<C_DIM,U_DIM>& G, Matrix<C_DIM>& h)
{
	Matrix<X_DIM,1> x;
	x.insert(0, 0, c);
	x.insert(C_DIM, 0, x0.subMatrix<L_DIM,1>(C_DIM,0));

	F.reset();
	Matrix<X_DIM> xr(x), xl(x), ddx;
	for (size_t i = 0; i < C_DIM; ++i) {
		xr[i] += step; xl[i] -= step;
		ddx = (dynfunc(xr, u, zeros<Q_DIM,1>()) - dynfunc(xl, u, zeros<Q_DIM,1>())) / (xr[i] - xl[i]);
		F.insert(0,i, ddx.subMatrix<C_DIM,1>(0, 0));
		xr[i] = x[i]; xl[i] = x[i];
	}

	G.reset();
	Matrix<U_DIM> ur(u), ul(u);
	Matrix<X_DIM> ddg;
	for (size_t i = 0; i < U_DIM; ++i) {
		ur[i] += step; ul[i] -= step;
		ddg = (dynfunc(x, ur, zeros<Q_DIM,1>()) - dynfunc(x, ul, zeros<Q_DIM,1>())) / (ur[i] - ul[i]);
		G.insert(0,i, ddg.subMatrix<C_DIM,1>(0, 0));
		ur[i] = u[i]; ul[i] = u[i];
	}

	h = dynfunc(x, u, zeros<Q_DIM,1>()).subMatrix<C_DIM,1>(0,0);
}
Esempio n. 6
0
xercesc::DOMElement * CrisprParser::getWantedGroupFromRoot(xercesc::DOMElement * parentNode, 
                                                                  std::string& wantedGroup, 
                                                                  std::string&  directRepeat)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling())        
    {
        if (xercesc::XMLString::equals(currentElement->getTagName(), tag_Group()))
        {
            // new group
            // test if it's one that we want
            char * c_group_name = tc(currentElement->getAttribute(attr_Gid()));
            std::string current_group_name = c_group_name;
            xr(&c_group_name);
            if (current_group_name == wantedGroup) 
            {
                // get the length of the direct repeat
                char * c_dr = tc(currentElement->getAttribute(attr_Drseq()));
                directRepeat = c_dr;
                return currentElement;
            }
        }
        
    }
    
    // we should theoretically never get here but if the xml is bad then it might just happen
    // or if the user has put in a group that doesn't exist by mistake
    return NULL;
}
Esempio n. 7
0
void CrisprParser::parseAssemblyForContigIds(xercesc::DOMElement* parentNode, 
                                                    std::set<std::string>& wantedReads, 
                                                    Spacer2SourceMap& spacersForAssembly,
                                                    XMLIDMap& source2acc, 
                                                    std::set<std::string>& wantedContigs)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling())        
    {
        if( xercesc::XMLString::equals(currentElement->getTagName(), tag_Contig()))
        {
            // check to see if the current contig is one that we want
            char * c_current_contig = tc(currentElement->getAttribute(attr_Cid()));
            std::string current_contig = c_current_contig;
            std::set<std::string>::iterator contig_iter = wantedContigs.find(current_contig);
            if( contig_iter != wantedContigs.end())
            {
                // get the spacers from the assembly
                getSourceIdForAssembly(currentElement, wantedReads, spacersForAssembly, source2acc);
            }
            xr(&c_current_contig);
        }
        
    }
}
Esempio n. 8
0
static void paintLinesToChildren( QGraphicsItem * qgi,
				  QPainter * painter,
				  QPen const & pen )
{
    typedef QList<QGraphicsItem*> QGIL;
    QGIL ch( qboard::childItems(qgi) );

    if( ch.isEmpty() ) return;
    QRectF prect( qgi->boundingRect() );
    QPointF mid( prect.left() + (prect.width() / 2),
		 prect.top() + (prect.height() / 2) );
    painter->save();
    for( QGIL::iterator it = ch.begin();
	 ch.end() != it; ++it )
    {
	QGraphicsItem * x = *it;
	QRectF xr( x->boundingRect() );
	QPointF xmid( xr.center() );
	//xmid = x->mapToParent( xmid );
	xmid = qgi->mapFromItem( x, xmid );
	painter->setPen( pen );
	painter->drawLine( QLineF( mid, xmid ) );
    }
    painter->restore();
}
Esempio n. 9
0
int main(){
  V3f x(0,0,1); V3f xr(rot_x(x, 0.87)); same("x rotation", x.dot(xr), cos(0.87));
  V3f y(0,0,1); V3f yr(rot_y(y, 0.23)); same("y rotation", y.dot(yr), cos(0.23));
  V3f z(1,0,0); V3f zr(rot_z(z, 0.19)); same("z rotation", z.dot(zr), cos(0.19));

  V3f nx(3,2,5);
  V3f ny(-2,3,4);
  V3f nz(-4,4,3.8);

  V3f nnx(3,2,5);
  V3f nny(-2,3,4);
  V3f nnz(-4,4,3.8);

  ortoNormalize(nnx, nny, nnz);
  
  same("x unit", nnx.length(), 1.0);
  same("y unit", nny.length(), 1.0);
  same("z unit", nnz.length(), 1.0);

  V3f tmp; tmp.cross(nnx, nx);

  same("x colinear", tmp.length(), 0.0);
  
  tmp.cross(nnx, nny); tmp-=nnz; same("x orto", tmp.length(), 0);
  tmp.cross(nny, nnz); tmp-=nnx; same("y orto", tmp.length(), 0);
  tmp.cross(nnz, nnx); tmp-=nny; same("z orto", tmp.length(), 0);


};
Esempio n. 10
0
void StatTool::parseMetadata(xercesc::DOMElement * parentNode, 
                             crispr::xml::base& xmlParser, 
                             StatManager * statManager) {
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {
        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_File())) {
            char * c_type_attr = tc(currentElement->getAttribute(xmlParser.attr_Type()));
            if (! strcmp(c_type_attr, "sequence")) {
                char * c_url = tc(currentElement->getAttribute(xmlParser.attr_Url()));
                statManager->setReadCount(calculateReads(c_url));
                xr(&c_url);
            }
            xr(&c_type_attr);
        }
    }
}
Esempio n. 11
0
 forceinline Iter::Ranges::CompareStatus
 ValSet::compare(View x) const {
   if (empty() || (x.max() < min()) || (x.min() > max()))
     return Iter::Ranges::CS_DISJOINT;
   ValSet::Ranges vsr(*this);
   ViewRanges<View> xr(x);
   return Iter::Ranges::compare(xr,vsr);
 }
Esempio n. 12
0
 forceinline bool
 ValSet::subset(View x) const {
   if (empty() || (x.min() < min()) || (x.max() > max()))
     return false;
   ValSet::Ranges vsr(*this);
   ViewRanges<View> xr(x);
   return Iter::Ranges::subset(xr,vsr);
 }
Esempio n. 13
0
bool AztecOOSolver::solve()
{
#ifdef HAVE_AZTECOO
	assert(m.size == rhs.size);

	// no output
	aztec.SetAztecOption(AZ_output, AZ_none);	// AZ_all | AZ_warnings | AZ_last | AZ_summary

#ifndef COMPLEX
	// setup the problem
	aztec.SetUserMatrix(m.mat);
	aztec.SetRHS(rhs.vec);
	Epetra_Vector x(*rhs.std_map);
	aztec.SetLHS(&x);

	if (pc != NULL) {
		Epetra_Operator *op = pc->get_obj();
		assert(op != NULL);		// can work only with Epetra_Operators
		aztec.SetPrecOperator(op);
	}

	// solve it
	aztec.Iterate(max_iters, tolerance);

	delete [] sln;
	sln = new scalar[m.size];
	memset(sln, 0, m.size * sizeof(scalar));

	// copy the solution into sln vector
	for (int i = 0; i < m.size; i++) sln[i] = x[i];
#else
	double c0r = 1.0, c0i = 0.0;
	double c1r = 0.0, c1i = 1.0;

	Epetra_Vector xr(*rhs.std_map);
	Epetra_Vector xi(*rhs.std_map);

	Komplex_LinearProblem kp(c0r, c0i, *m.mat, c1r, c1i, *m.mat_im, xr, xi, *rhs.vec, *rhs.vec_im);
	Epetra_LinearProblem *lp = kp.KomplexProblem();
	aztec.SetProblem(*lp);

	// solve it
	aztec.Iterate(max_iters, tolerance);

	kp.ExtractSolution(xr, xi);

	delete [] sln;
	sln = new scalar[m.size];
	memset(sln, 0, m.size * sizeof(scalar));

	// copy the solution into sln vector
	for (int i = 0; i < m.size; i++) sln[i] = scalar(xr[i], xi[i]);
#endif
	return true;
#else
	return false;
#endif
}
Esempio n. 14
0
 inline std::string
 Comparator::compare(std::string x_n, IntVar x, IntVar y) {
   IntVarRanges xr(x), yr(y);
   if (!Iter::Ranges::equal(xr,yr)) {
     std::ostringstream ret;
     ret << x_n << "=" << x << " -> " << y;
     return ret.str();
   }
   return "";
 }
Esempio n. 15
0
void SanitiseTool::parseSpacers(xercesc::DOMElement * parentNode, 
                                crispr::xml::writer& xmlParser)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {

        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Spacer())) {
            char * c_spid = tc(currentElement->getAttribute(xmlParser.attr_Spid()));
            std::string spid = c_spid;
            ST_SpacerMap[spid] = getNextSpacerS();
            xr(&c_spid);
            XMLCh * x_next_spacer_num = tc(getNextSpacerS().c_str());
            currentElement->setAttribute(xmlParser.attr_Spid(), x_next_spacer_num);
            xr(&x_next_spacer_num);
            incrementSpacer();
        }
    }
}
Esempio n. 16
0
inline Matrix<_zDim,_xDim> dhdx(Matrix<_zDim> (*h)(const Matrix<_xDim>&), const Matrix<_xDim>& x) 
{
	Matrix<_zDim,_xDim> H;
	Matrix<_xDim> xr(x), xl(x);
	for (size_t i = 0; i < _xDim; ++i) {
		xr[i] += step; xl[i] -= step;
		H.insert(0,i, (h(xr) - h(xl)) / (2.0*step));
		xr[i] = xl[i] = x[i];
	}
	return H;
}
Esempio n. 17
0
inline Matrix<_xDim,_xDim> dfdx(Matrix<_xDim> (*f)(const Matrix<_xDim>&, const Matrix<_uDim>&), const Matrix<_xDim>& x, const Matrix<_uDim>& u) 
{
	Matrix<_xDim,_xDim> A;
	Matrix<_xDim> xr(x), xl(x);
	for (size_t i = 0; i < _xDim; ++i) {
		xr[i] += step; xl[i] -= step;
		A.insert(0,i, (f(xr, u) - f(xl, u)) / (2.0*step));
		xr[i] = xl[i] = x[i];
	}
	return A;
}
Esempio n. 18
0
void DrawTool::parseGroup(xercesc::DOMElement * parentNode, crispr::xml::parser& xmlParser)
{

    
    // create a new graph object
    char * c_gid = tc(parentNode->getAttribute(xmlParser.attr_Gid()));
    crispr::graph * current_graph = new crispr::graph(c_gid);
    xr(&c_gid);
    // change the max and min coverages back to their original values
    resetInitialLimits();
    
    DT_Graphs.push_back(current_graph);
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {
        
        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Data())) {
            parseData(currentElement, xmlParser, current_graph);
            setColours();
        } else if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Assembly())) {
            parseAssembly(currentElement, xmlParser, current_graph);
        }
        
    }
    
    char * c_file_prefix = tc(parentNode->getAttribute(xmlParser.attr_Gid()));
    std::string file_prefix = c_file_prefix;
    std::string file_name = file_prefix + "." + DT_OutputFormat;
    xr(&c_file_prefix);
    char * file_name_c = strdup(file_name.c_str());

    layoutGraph(current_graph->getGraph(), DT_RenderingAlgorithm);
    renderGraphToFile(current_graph->getGraph(), DT_OutputFormat, file_name_c);
    freeLayout(current_graph->getGraph());
    // free the duplicated string
    try {
        delete file_name_c;
    } catch (std::exception& e) {
        std::cerr<<e.what()<<std::endl;
    }
}
Esempio n. 19
0
void SanitiseTool::parseContig(xercesc::DOMElement * parentNode, 
                               crispr::xml::writer& xmlParser)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {

        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Cspacer())) {
            if (ST_Spacers) {
                char * c_spid = tc( currentElement->getAttribute(xmlParser.attr_Spid()));
                std::string spid = c_spid;
                XMLCh * x_new_spid = tc(ST_SpacerMap[spid].c_str());
                currentElement->setAttribute(xmlParser.attr_Spid(), x_new_spid);
                xr(&c_spid);
                xr(&x_new_spid);
            }
            if (ST_Spacers || ST_Repeats || ST_Flank) {
                parseCSpacer(currentElement, xmlParser);
            }
        }
    }
}
Esempio n. 20
0
osg::Quat KeyframeController::getXYZRotation(float time) const
{
    float xrot = 0, yrot = 0, zrot = 0;
    if (!mXRotations.empty())
        xrot = mXRotations.interpKey(time);
    if (!mYRotations.empty())
        yrot = mYRotations.interpKey(time);
    if (!mZRotations.empty())
        zrot = mZRotations.interpKey(time);
    osg::Quat xr(xrot, osg::Vec3f(1,0,0));
    osg::Quat yr(yrot, osg::Vec3f(0,1,0));
    osg::Quat zr(zrot, osg::Vec3f(0,0,1));
    return (xr*yr*zr);
}
Esempio n. 21
0
void StatTool::parseSpacers(xercesc::DOMElement * parentNode, 
                            crispr::xml::base& xmlParser, 
                            StatManager * statManager)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {

        char * c_spacer = tc(currentElement->getAttribute(xmlParser.attr_Seq()));
        std::string spacer = c_spacer;
        xr(&c_spacer);
        statManager->addSpLenVec(static_cast<int>(spacer.length()));
        char * c_cov = tc(currentElement->getAttribute(xmlParser.attr_Cov()));
        std::string cov = c_cov;
        xr(&c_cov);
        if (!cov.empty()) {
            int cov_int;
            from_string(cov_int, cov, std::dec);
            statManager->addSpCovVec(cov_int);
        }
        statManager->incrementSpacerCount();
    }
}
Esempio n. 22
0
 ExecStatus
 Distinct<View0,View1>::propagate(Space& home, const ModEventDelta&) {
   assert(x0.assigned()||x1.assigned());
   if (x0.assigned()) {
     GlbRanges<View0> xr(x0);
     IntSet xs(xr);
     ConstSetView cv(home, xs);
     GECODE_REWRITE(*this,(DistinctDoit<View1>::post(home(*this),x1,cv)));
   } else {
     GlbRanges<View1> yr(x1);
     IntSet ys(yr);
     ConstSetView cv(home, ys);
     GECODE_REWRITE(*this,(DistinctDoit<View0>::post(home(*this),x0,cv)));
   }
 }
Esempio n. 23
0
void StatTool::parseFlankers(xercesc::DOMElement * parentNode, 
                             crispr::xml::base& xmlParser, 
                             StatManager * statManager)
{
    
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {
        
        char * c_flanker = tc(currentElement->getAttribute(xmlParser.attr_Seq()));
        std::string flanker = c_flanker;
        xr(&c_flanker);
        statManager->addFlLenVec(static_cast<int>(flanker.length()));
        statManager->incrementFlankerCount();
    }
}
Esempio n. 24
0
void SanitiseTool::parseAssembly(xercesc::DOMElement * parentNode, 
                                 crispr::xml::writer& xmlParser)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {

        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Contig())) {
            XMLCh * x_next_contig = tc(getNextContigS().c_str());
            currentElement->setAttribute(xmlParser.attr_Cid(), x_next_contig);
            incrementContig();
            xr(&x_next_contig);
            parseContig(currentElement, xmlParser);
        }
    }
}
Esempio n. 25
0
int SanitiseTool::processInputFile(const char * inputFile)
{
    try {
        crispr::xml::parser xml_parser;
        xercesc::DOMDocument * input_doc_obj = xml_parser.setFileParser(inputFile);
        xercesc::DOMElement * root_elem = input_doc_obj->getDocumentElement();
        if (!root_elem) {
            throw crispr::xml_exception(__FILE__, 
                                        __LINE__, 
                                        __PRETTY_FUNCTION__, 
                                        "problem when parsing xml file");
        }
        if (ST_OutputFile.empty()) {
            ST_OutputFile = inputFile;
        }

        for (xercesc::DOMElement * currentElement = root_elem->getFirstElementChild(); 
             currentElement != NULL; 
             currentElement = currentElement->getNextElementSibling()) {

                
                // is this a group element
                if (xercesc::XMLString::equals(currentElement->getTagName(), xml_parser.tag_Group())) {
                    
                    XMLCh * x_next_group_num = tc( getNextGroupS().c_str());
                    currentElement->setAttribute(xml_parser.attr_Gid(), x_next_group_num);
                    incrementGroup();
                    xr(&x_next_group_num);
                    // the user wants to change any of these 
                    if (ST_Spacers || ST_Repeats || ST_Flank || ST_contigs) {
                        parseGroup(currentElement, xml_parser);
                    }
                }
            
            setNextRepeat(1);
            setNextContig(1);
            setNextRepeat(1);
            setNextSpacer(1);
        }
        xml_parser.printDOMToFile(ST_OutputFile, input_doc_obj);
    } catch (crispr::xml_exception& e) {
        std::cerr<<e.what()<<std::endl;
        return 1;
    }
    
    return 0;
}
Esempio n. 26
0
    void Player::setRot(float x, float y, float z)
    {
            Ogre::SceneNode *sceneNode = mNode;
            Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
            Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();

            // we are only interested in X and Y rotation

            // Rotate around X axis
            Ogre::Quaternion xr(Ogre::Radian(x), Ogre::Vector3::UNIT_X);

            // Rotate around Y axis
            Ogre::Quaternion yr(Ogre::Radian(-z), Ogre::Vector3::UNIT_Y);

            pitchNode->setOrientation(xr);
            yawNode->setOrientation(yr);
    }
Esempio n. 27
0
 ExecStatus
 Distinct<View0,View1>::post(Home home, View0 x, View1 y) {
   if (x.assigned()) {
     GlbRanges<View0> xr(x);
     IntSet xs(xr);
     ConstSetView cv(home, xs);
     GECODE_ES_CHECK((DistinctDoit<View1>::post(home,y,cv)));
   }
   if (y.assigned()) {
     GlbRanges<View1> yr(y);
     IntSet ys(yr);
     ConstSetView cv(home, ys);
     GECODE_ES_CHECK((DistinctDoit<View0>::post(home,x,cv)));
   }
   (void) new (home) Distinct<View0,View1>(home,x,y);
   return ES_OK;
 }
Esempio n. 28
0
    void Camera::rotateCamera(const Ogre::Vector3 &rot, bool adjust)
    {
        if (adjust) {
            setYaw(getYaw() + rot.z);
            setPitch(getPitch() + rot.x);
        } else {
            setYaw(rot.z);
            setPitch(rot.x);
        }

        Ogre::Quaternion xr(Ogre::Radian(getPitch() + Ogre::Math::HALF_PI), Ogre::Vector3::UNIT_X);
        if (!mVanity.enabled && !mPreviewMode) {
            mCamera->getParentNode()->setOrientation(xr);
        } else {
            Ogre::Quaternion zr(Ogre::Radian(getYaw()), Ogre::Vector3::UNIT_Z);
            mCamera->getParentNode()->setOrientation(zr * xr);
        }
    }
Esempio n. 29
0
void CSVRender::Object::adjustTransform()
{
    if (mReferenceId.empty())
        return;

    const CSMWorld::CellRef& reference = getReference();

    // position
    mBaseNode->setPosition(mForceBaseToZero ? osg::Vec3() : osg::Vec3f(reference.mPos.pos[0], reference.mPos.pos[1], reference.mPos.pos[2]));

    // orientation
    osg::Quat xr (-reference.mPos.rot[0], osg::Vec3f(1,0,0));
    osg::Quat yr (-reference.mPos.rot[1], osg::Vec3f(0,1,0));
    osg::Quat zr (-reference.mPos.rot[2], osg::Vec3f(0,0,1));
    mBaseNode->setAttitude(zr*yr*xr);

    mBaseNode->setScale(osg::Vec3(reference.mScale, reference.mScale, reference.mScale));
}
Esempio n. 30
0
int DrawTool::processInputFile(const char * inputFile)
{
    try {
        crispr::xml::parser xml_parser;
        xercesc::DOMDocument * input_doc_obj = xml_parser.setFileParser(inputFile);
        xercesc::DOMElement * root_elem = input_doc_obj->getDocumentElement();
        
        if( !root_elem ) throw(crispr::xml_exception(__FILE__, 
                                                     __LINE__, 
                                                     __PRETTY_FUNCTION__, 
                                                     "empty XML document" ));

        // get the children
        for (xercesc::DOMElement * currentElement = root_elem->getFirstElementChild(); 
             currentElement != NULL; 
             currentElement = currentElement->getNextElementSibling()) {
                
            // is this a group element
            if (xercesc::XMLString::equals(currentElement->getTagName(), xml_parser.tag_Group())) {
                char * c_group_id = tc(currentElement->getAttribute(xml_parser.attr_Gid()));
                std::string group_id = c_group_id;
                if (DT_Subset) {
                    
                    // we only want some of the groups look at DT_Groups
                    if (DT_Groups.find(group_id.substr(1)) != DT_Groups.end() ) {
                        parseGroup(currentElement, xml_parser);
                        
                    }
                } else {
                    parseGroup(currentElement, xml_parser);   
                }
                xr(&c_group_id);
            }
            
        }
    } catch (crispr::xml_exception& e) {
        std::cerr<<e.what()<<std::endl;
        return 1;
    } catch (crispr::runtime_exception& e) {
        std::cerr<<e.what()<<std::endl;
    }
    
    return 0;
}