Exemplo n.º 1
0
void DigiSpeMeasuringPoint::createTriangle(Sample* a, Sample* b, Sample* c, bool addToTriangleA, bool triangulationTriangle)
{
	if (triangulate && !triangulationTriangle)
		return;	// TODO: Account for manual triangles when triangulating

	Triangle* newTriangle = new Triangle();

	newTriangle->a = a;
	newTriangle->b = b;
	newTriangle->c = c;
	createLine(a, b, false, true, &newTriangle->ab, triangulationTriangle);
	createLine(b, c, false, true, &newTriangle->bc, triangulationTriangle);
	createLine(c, a, false, true, &newTriangle->ca, triangulationTriangle);

	// Adjust the line N vectors so that they point in the direction of the remaining triangle corner
	triangleAdjustN(newTriangle->ab, c);
	triangleAdjustN(newTriangle->bc, a);
	triangleAdjustN(newTriangle->ca, b);
	
	// Calculate triangle plane data
	newTriangle->area.redefine(a->dir*a->len, b->dir*b->len, c->dir*c->len);

	// Add the triangle to the list
	triangles.push_back(newTriangle);
	
	if (addToTriangleA)
		a->triangleA.push_back(newTriangle);
}
Exemplo n.º 2
0
void Testing::printStatistic() {
	string str = "";
	str += createLine("=") + nl;
	str += "FAILED ASSERTIONS:";

	int nFailedTests = 0;
	for (auto test : runTests) {
		if (test.hasFailed()) {
			nFailedTests++;
			str += nl + createLine("-");
			str += nl + test.getErrorDescription(indentString);
		}
	}
	if (nFailedTests <= 0) {
		str += " none";
	}

	str += nl + createLine("=") + nl;
	str += estr + "Ran " + getTestPercentage() + ", ";
	str += testCountToString(nFailedTests) + " failed." + nl;
	if (nFailedTests > 0)
		str += ">>> RED <<<" + nl;
	else 
		str += "__ GREEN __" + nl;
	print(str);
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------------
RepeatRangeWindow::RepeatRangeWindow( QWidget* parent, const char* name )
  : QVBox( parent, name ? name : "RepeatRangeWindow" )
{
  setSpacing( 6 );

  _group = new QVButtonGroup( i18n("Times to Match"), this, "groupbox" );

  // Any number of times
  QRadioButton* radioBut = new QRadioButton(i18n("Any number of times (including zero times)"),
                                            _group,
                                            "RepeatRangeWindow::choice any times");

  _group->insert(radioBut, ANY);

  QWidget* container = new QWidget( _group );
  QHBoxLayout* lay = new QHBoxLayout( container );
  QGrid* grid = new QGrid( 3, container );
  grid->setSpacing( 5 );

  lay->addWidget( grid );
  lay->addStretch( 1 );

  createLine( grid, i18n( "At least" ), &_leastTimes, ATLEAST );
  createLine( grid, i18n( "At most" ), &_mostTimes, ATMOST );
  createLine( grid, i18n( "Exactly" ), &_exactlyTimes, EXACTLY );

  // from ___ to ___ times
  radioBut = new QRadioButton(i18n( "From" ), grid, "RepeatRangeWindow::from");
  _group->insert( radioBut, MINMAX );

  _rangeFrom = new QSpinBox( 1, 999, 1, grid);

  QHBox* box = new QHBox( grid );
  box->setSpacing( 5 );

  (void) new QLabel(i18n( "to" ), box);
  _rangeTo = new QSpinBox( 1, 999, 1, box );
  (void) new QLabel( i18n( "time(s)" ), box );

  connect( _rangeFrom, SIGNAL( valueChanged( int ) ), this, SLOT( slotUpdateMaxVal( int ) ) );
  connect( _rangeTo, SIGNAL( valueChanged( int ) ), this, SLOT( slotUpdateMinVal( int ) ) );

  // set a default button.
  _group->setButton(ANY);
  slotItemChange( ANY );


  connect( _group, SIGNAL( clicked( int ) ), this, SLOT( slotItemChange( int ) ) );
}
Exemplo n.º 4
0
int main(){

	Line l = createLine(1,2,1,4);
	assert(checkLine(l)==1);

	l = createLine(2,4,1,4);
	assert(checkLine(l)==2);

	l = createLine(2,3,1,4);
	assert(checkLine(l)==3);

	/*l = createLine(4,4,4,4);// this will abort */

	return 0;
}
Exemplo n.º 5
0
bool WaterObjectView::load()
{
	if (mIsLoaded)
	{
		return false;			
	}

	if (mWaterObject->getMap() != mMapView->getMap())
	{
		return false;
	}

	if (mWaterObject->getPointCount() == 1)
	{
		createPoint();
	}
	else if (mWaterObject->getIsRiver() || (mWaterObject->getPointCount() == 2))
	{
		createLine();
	}
	else
	{
		createPolygon();
	}

	mEntity = mMapView->createEntity(mMesh->getName(), mMesh->getName());
	mEntity->setUserAny(Ogre::Any(this));

	mSceneNode = mMapView->createSceneNode();
	mSceneNode->attachObject(mEntity);

	return mIsLoaded = true;
}
Exemplo n.º 6
0
    template <typename P1, typename P2> bool
    PCLVisualizer::addLine (const P1 &pt1, const P2 &pt2, double r, double g, double b, const std::string &id, int viewport)
    {
      // Check to see if this ID entry already exists (has it been already added to the visualizer?)
      ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
      if (am_it != shape_actor_map_->end ())
      {
        PCL_WARN ("[addLine] A shape with id <%s> already exists! Please choose a different id and retry.\n", id.c_str ());
        return (false);
      }

      vtkSmartPointer<vtkDataSet> data = createLine (pt1.getVector4fMap (), pt2.getVector4fMap ());

      // Create an Actor
      vtkSmartPointer<vtkLODActor> actor;
      createActorFromVTKDataSet (data, actor);
      actor->GetProperty ()->SetRepresentationToWireframe ();
      actor->GetProperty ()->SetColor (r, g, b);
  actor->GetMapper ()->ScalarVisibilityOff ();
  addActorToRenderer (actor, viewport);

  // Save the pointer/ID pair to the global actor map
  (*shape_actor_map_)[id] = actor;
      return (true);
}
/**
 * This method is a implementation of the method with the same name defined in the interface IFilterConfigurationDAO.
 * In this case the Line object which corresponds to the right line is created with information stored in a text file, this
 * method reads the text file searching a right line tag to find the information and creates a Line object. In case of the
 * information related with the right line object cannot be found in the text file this method returns a null pointer.<p>
 */
Line* FileReader::getRightLine(){
	string right_line_information;
	findDataByTag(RIGH_LINE_TAG, right_line_information);
	Line* p_right_line = createLine(right_line_information);
	if(!p_right_line){
		cerr << "Error: RightLine's information in the file is incorrect." << endl;
	}
	return p_right_line;
}
/**
 * This method is a implementation of the method with the same name defined in the interface IFilterConfigurationDAO.
 * In this case the Line object which corresponds to the left line is created with information stored in a text file, this
 * method reads the text file searching a left line tag to find the information and creates a Line object.In case of the
 * information related with the left line object cannot be found in the text file this method returns a null pointer.<p>
 */
Line* FileReader::getLeftLine(){
	string left_line_information;
	findDataByTag(LEFT_LINE_TAG, left_line_information);
	Line* p_left_line = createLine(left_line_information);
	if(!p_left_line){
		cerr << "Error: LeftLine's information in the file is incorrect." << endl;
	}
	return p_left_line;
}
Exemplo n.º 9
0
void dbgGraphWindow::messageCreated(operTrDef::messageID message, int pos, int added, int removed, QString addText, operTrDef::changes appliedChanges)
{
    QTime time= QTime::currentTime();
    int long actTime=mCreationTime.msecsTo(time);
    operTrDef::clientID priority= static_cast<operTr*>(sender())->getPriority();
    //vertical line
    createLine(priority, time);
    
    mMessages.insert(message, messInit(actTime, priority));
}
Exemplo n.º 10
0
//print caminho no svg
void* svgCaminho(void *listaArestas, char *cor, double* inic, double* end){
    if(listaArestas == NULL)    return NULL;
    void *itemA, *itemB, *svg, *notation, *posic;
    ArestaP *ar1, *ar2;
    char *svgCode;

    Lista result = Lista_createLista();
    if(Lista_lenght(listaArestas) == 0){
        notation = createNotacao(cor, *inic, *(inic+1), *end, *(end+1), "");
        svgCode = createLine(notation);
        Lista_insert(result, svgCode);
        return result;
    }

    if(inic != NULL){
        ar2 = Lista_get(listaArestas, Lista_getFirst(listaArestas));    
        notation = createNotacao(cor, *inic, *(inic+1), ar2->v1->x, ar2->v1->y, "");
        svgCode = createLine(notation);
        Lista_insert(result, svgCode);
    }

    posic = Lista_getFirst(listaArestas);    
    while(posic != NULL){

        ar1 = (ArestaP *) Lista_get(listaArestas, posic);
        if(ar1){
            notation = createNotacao(cor, ar1->v1->x, ar1->v1->y, ar1->v2->x, ar1->v2->y, "");
            svgCode = createLine(notation);
            Lista_insert(result, svgCode);
        }
        posic  = Lista_getNext(listaArestas, posic);
    }    
    if(end != NULL){
        ar1 = Lista_get(listaArestas, Lista_getLast(listaArestas));    
        notation = createNotacao(cor, ar1->v2->x, ar1->v2->y, *end, *(end+1), "");
        svgCode = createLine(notation);
        Lista_insert(result, svgCode);
    }
    
    return result;
}
int addSentenceData(char* sentence)
{
	int i = 0;
	sentenceData* targetData = createSentenceData();
	
	targetData->value = createLine();
	targetData->value = (char*)realloc(targetData->value, sizeof(char)* (strlen(sentence)+1) );
	
	for (i = 0; i < strlen(sentence) + 1; i++)
		targetData->value[i] = sentence[i];
	
	return setSentenceDataHead(targetData);
}
Exemplo n.º 12
0
void dbgGraphWindow::messageDelivered(operTrDef::messageID messID, int pos, int added, int removed, QString addText, operTrDef::changes appliedChanges)
{
    QTime time=QTime::currentTime();
    operTrDef::clientID receiver=static_cast<operTr*>(sender())->getPriority();
    
    QTextDocument document;
    document.setHtml(addText);
    addText=document.toPlainText();
    
    
    if(mMessages.count(messID)==0)
        throw QString("message ID was not created");
    
    int long startTime=mMessages.value(messID).time;
    long int actTime=mCreationTime.msecsTo(QTime::currentTime()); 
    
    if(actTime>mMaxTime){
        mMaxTime=actTime;
    }

    //arrow
    QString mess;
    if(!addText.isEmpty())
        mess+="ins("+QString().number(pos)+", "+addText+");";
    if(removed)
        mess+="rem("+QString().number(pos)+", "+QString().number(removed)+");";
    
    
    QString applCh;
    if(!appliedChanges.isEmpty()){
        applCh="<BR>applied changes:<BR>";
        foreach(operTrDef::messageID mid, appliedChanges)
            applCh+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+QString().number(mid.mClientID)+"->"+QString().number(mid.mMessageNumber)+"<BR>";
    }
    
    
    createArrow(mMessages.value(messID).sender*clientPrToPixelsCoef+rightShitf,
                    startTime*pixelsPerMilisecond,
                    receiver*clientPrToPixelsCoef+rightShitf,
                    actTime*pixelsPerMilisecond,
                    "ID:"+QString().number(messID.mClientID)+"->"+QString().number(messID.mMessageNumber)+"<BR>"+
                    "pos:"+QString().number(pos)+", rem: "+QString().number(removed)+", text: "+addText+
                    applCh
               );
    //text for arrow
    mScene->addText(mess)->setPos(mMessages.value(messID).sender*clientPrToPixelsCoef+rightShitf+20, startTime*pixelsPerMilisecond-15);
    
    //vertical line
    createLine(receiver, time);
    
}
Exemplo n.º 13
0
void HighScore::createPage(const QString &lbl)
{
    int i;
    QVBoxLayout *vLayout = new QVBoxLayout;

    for(i = 0; i < 10; ++i) {
        vLayout->addWidget(createLine());
    }

    QWidget *page = new QWidget;
    page->setLayout(vLayout);

    tabWidget->addTab(page, lbl);
}
Exemplo n.º 14
0
void Testing::runAllTests() {
	println(createLine("="));
	pln(estr + "RUNNING ALL TESTS (" + testcases.size() + " testfiles with " + testCountToString(getTestCount()) + ")")
	vector<string> keys;
	for (auto entry : testcases) {
		keys.push_back(entry.first);
	}
	auto cmp = [](String a, String b) {
		a = a.toLower();
		b = b.toLower();
		return a.compare(b) < 0;
	};
	sort(keys.begin(),keys.end(), cmp);
	for (auto key : keys) {
		runTestfile(key);
	}
	printStatistic();
}
char* getLine(FILE* fp)
{
	char* line = createLine();
	char buf;
	int lineLength = 1;

	while (1)
	{
		buf = fgetc(fp);
		if ('\n' == buf || feof(fp)) break;
		lineLength++;

		line = (char*)realloc(line, sizeof(char)*lineLength);
		line[lineLength - 2] = buf;
	}
	line[lineLength - 1] = '\0';
	return line;
}
Exemplo n.º 16
0
/**
  * Add a line of script to the function:
  * Scalar x = 1;
  * Scalar y = 2;
  * Scalar z;
  * z = x + y;
  */
void ScriptLineBlock::addScript(const std::string& script)
{
    ScriptParser parser;
    parser.parse( script );
    const size_t n = parser.size();
    for(size_t i = 0; i < n; ++i)
    {
        auto line = createLine( parser.line( i ) );
        if ( line )
        {
            m_lines.push_back(ScriptLine_ptr(line));
        }
        else
        {
            throw std::runtime_error("Cannot create script line: " + boost::lexical_cast<std::string>(i));
        }
    }
}
Exemplo n.º 17
0
int main(int argc, char const *argv[])
{
	/* code */
	int tab[max];

	int opr ;
	if (argv[1] == NULL) opr =1;
	else opr = getOp(argv[1]);

	for (int i=0;i<max;i++)
	{
		tab[i] = i;
	}

	save(createLine(opr,tab,op(opr,tab)),tab);
    printf("\nDone\n\n");

	return 0;
}
Exemplo n.º 18
0
//=============================================================================
// Reset the graphics device
//=============================================================================
HRESULT Graphics::reset()
{
    safeRelease(line);
    safeRelease(pOcclusionQuery);       // release query
    initD3Dpp();                        // init D3D presentation parameters
    sprite->OnLostDevice();             // release sprite
    result = device3d->Reset(&d3dpp);   // attempt to reset graphics device

    // Configure for alpha blend of primitives
    device3d->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
    device3d->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    device3d->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

    // recreate query
    device3d->CreateQuery(D3DQUERYTYPE_OCCLUSION, &pOcclusionQuery);
    sprite->OnResetDevice();            // recreate sprite
    createLine(&line);                  // recreate a DirectX line
    return result;
}
Exemplo n.º 19
0
OGLine::OGLine(WOGLine *line, WOGMaterial* material)
    : OGIBody(line, material)
{
    OGPhysicsBody* obj;

    QPointF anchor = line->anchor;
    QPointF normal = line->normal;

    if (!line->dynamic)
    {
        OGUserData* data = new OGUserData;
        data->type = OGUserData::GEOM;
        data->data = this;
        obj = createLine(anchor, normal, material, false, data);
    }

    body = obj->body;
    fixture = obj->fixture;
    shape = obj->shape;
}
Exemplo n.º 20
0
void
	Player::drawLine(std::string bone, int joint1, int joint2)
{
	if (!initSkel)
		createLine(bone, joint1, joint2);
	else if (initSkel)
	{
		vector<Ogre::Vector3> skeletonNodes = mKinect->getSkeletonNodes();
		Ogre::ManualObject* myManualObject = mSceneManager->getManualObject(bone);

		myManualObject->clear();

		Ogre::Vector3 bone1 = 20 * skeletonNodes[joint1] + Ogre::Vector3(-50, 30, 20);
		Ogre::Vector3 bone2 = 20 * skeletonNodes[joint2] + Ogre::Vector3(-50, 30, 20);

		myManualObject->begin(bone + "Material", Ogre::RenderOperation::OT_LINE_LIST);
		myManualObject->position(bone1.x, bone1.y, bone1.z); 
		myManualObject->position(bone2.x, bone2.y, bone2.z); 
		myManualObject->end();
	}
}
Exemplo n.º 21
0
  ViewerWidget(QWidget* parent = 0,Qt::WindowFlags f = 0,osgViewer::ViewerBase::ThreadingModel threadingModel=osgViewer::CompositeViewer::SingleThreaded): QWidget(parent,f)
  {
    setThreadingModel(threadingModel);

    // disable the default setting of viewer.done() by pressing Escape.
    setKeyEventSetsDone(0);


    osg::ref_ptr<osg::Node> line = createLine(osg::Vec3(-2,0,2),osg::Vec3(2,0,2));
    osgSim::OverlayNode* overlayNode = new osgSim::OverlayNode(
      osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY);
    overlayNode->setContinuousUpdate(true);
    overlayNode->setOverlaySubgraph(line);
    overlayNode->setOverlayBaseHeight(0.99);
    osg::ref_ptr<osg::Node> cube = osgDB::readNodeFile("cube.osgb");
    overlayNode->addChild(cube);
    osg::ref_ptr<osg::Group> root = new osg::Group;
    root->addChild(overlayNode);
    root->addChild(line);

    QWidget* widget1 = addViewWidget( createGraphicsWindow(0,0,100,100), osgDB::readRefNodeFile("cow.osgt") );
//     QWidget* widget1 = addViewWidget(createGraphicsWindow(0,0,100,100),root);
    QWidget* widget2 = addViewWidget(createGraphicsWindow(0,0,100,100),osgDB::readRefNodeFile("glider.osgt"));
    QWidget* widget3 = addViewWidget(createGraphicsWindow(0,0,100,100),osgDB::readRefNodeFile("axes.osgt"));
    QWidget* widget4 = addViewWidget(createGraphicsWindow(0,0,100,100),osgDB::readRefNodeFile("fountain.osgt"));
    QWidget* popupWidget = addViewWidget(createGraphicsWindow(900,100,320,240,"Popup window",true),osgDB::readRefNodeFile("dumptruck.osgt"));
    popupWidget->show();

    QGridLayout* grid = new QGridLayout;
    grid->addWidget(widget1,0,0);
    grid->addWidget(widget2,0,1);
    grid->addWidget(widget3,1,0);
    grid->addWidget(widget4,1,1);
    setLayout(grid);

    connect(&_timer,SIGNAL(timeout()),this,SLOT(update()));
    _timer.start(10);
  }
Exemplo n.º 22
0
coVR1DTransInteractor::coVR1DTransInteractor(pfVec3 o, pfVec3 d, float min, float max, float val, float size, int showConstr, char *name)
{
   pfMatrix wm, tm, sm;
   pfVec3 zaxis(0,0,1);

   origin = o;
   dir = d;
   dir.normalize();
   minVal = min;
   maxVal = max;
   currVal = val;
   interSize = size;
   interactorName= new char[strlen(name)+1];
   strcpy(interactorName, name);
   if ((showConstr == SHOW_CONSTRAINTS_ALWAYS)
      || (showConstr == SHOW_CONSTRAINTS_ONTOUCH)
      || (showConstr == SHOW_CONSTRAINTS_ONSELECT))
      showConstraints = showConstr;

   else
   {
      fprintf(stderr,"\nERROR in coVR1DTransInteractor::coVR1DTransInteractor\n");
      fprintf(stderr,"\tillegal value [%d] for showConstraints\n", showConstr);

      showConstraints = SHOW_CONSTRAINTS_ALWAYS;
   }
   float interScale = size/cover->getScale();
   fprintf(stderr,"interactor size=%f cover scale = %f\n", interSize, cover->getScale());
   // initialize flags

   interactionOngoing = false;
   isI = false;
   isS = false;
   isE = false;
   justHit = true;

   // get debug level
   const char *line = CoviseConfig::getEntry("COVERConfig.DEBUG_LEVEL");
   if (line)
      sscanf(line,"%d", &debugLevel);
   else
      debugLevel = 0;

   // debugprint
   if (debugLevel>0)
   {
      fprintf(stderr,"\ncoVR1DTransInteractor:coVR1DTransInteractor [%s]\n", interactorName);
      fprintf(stderr,"\tshowConstraints=[%d]\n", showConstraints);
      fprintf(stderr,"\torigin=[%f %f %f]\n", origin[0], origin[1], origin[2]);
      fprintf(stderr,"\tdir=[%f %f %f]\n", dir[0], dir[1], dir[2]);
      fprintf(stderr,"\tminVal=[%f] maxVal=[%f] currVal=[%f]\n", minVal, maxVal, currVal);

   }

   // check and adjust the ranges
   checkRange();

   // load geostates only once
   geostate = loadDefaultGeostate();
   unlightedGeostate = loadUnlightedGeostate();

   //       objectsRoot
   //            |
   //        worldDCS
   //            |
   //       interactorRoot
   //          |   |
   // lineGeode   sphereTransDCS
   //                  |
   //             sphereScaleDCS
   //                  |
   //             sphereGeode

   if(debugLevel>1)
      fprintf(stderr,"\tcreating the scenegraph\n");

   objectsRoot = cover->getObjectsRoot();

   worldDCS = new pfDCS();
   wm.makeVecRotVec(zaxis, dir);
   wm[3][0] = origin[0];
   wm[3][1] = origin[1];
   wm[3][2] = origin[2];
   worldDCS->setMat(wm);

   interactorRoot = new pfGroup();

   sphereTransDCS = new pfDCS();
   tm.makeTrans(0, 0, currVal);
   sphereTransDCS->setMat(tm);

   sphereScaleDCS = new pfDCS();
   sm.makeScale(interScale, interScale, interScale);
   sphereScaleDCS->setMat(sm);

   sphereGeode = createSphere();
   lineGeode = createLine();

   objectsRoot->addChild(worldDCS);
   worldDCS->addChild(interactorRoot);
   interactorRoot->addChild(lineGeode);
   interactorRoot->addChild(sphereTransDCS);
   sphereTransDCS->addChild(sphereScaleDCS);
   sphereScaleDCS->addChild(sphereGeode);

   if (showConstraints == SHOW_CONSTRAINTS_ALWAYS)
      showLine();
   else
      hideLine();

   if(debugLevel>1)
      fprintf(stderr,"\tcreating the highlights\n");

   // highlights
   isectedHl = new pfHighlight();
   isectedHl->setMode(PFHL_FILL);
   isectedHl->setColor(PFHL_FGCOLOR, 0.6, 0.6, 0.0);
   isectedHl->setLineWidth(3.0);

   selectedHl = new pfHighlight();
   selectedHl->setMode(PFHL_FILL);
   selectedHl->setColor(PFHL_FGCOLOR, 0.0, 0.6, 0.0);
   selectedHl->setLineWidth(3.0);

}
Exemplo n.º 23
0
int main(int argc, char** argv)
{
    initVect(120,40);

    /*
     * Building level 
     */

    initLander();
    

    addLine(createLine(0,20,10,25));
    addLine(createLine(10,24,17,29));
    addLine(createLine(17,29,23,35));

    platform1 = addLine(createLine(22,35,32,35)); // <- first platform

    addLine(createLine(32,34,40,30));
    line1 = addLine(createLine(40,30,43,20));
    addLine(createLine(43,20,48,15));
    line3 = addLine(createLine(48,15,58,20));
    addLine(createLine(57,20,75,18));
    line2 = addLine(createLine(75,18,85,26));

    platform2 = addLine(createLine(84,26,94,26)); // <- second platform
    addLine(createLine(94,25,105,15));
    addLine(createLine(105,14,120,11));

    addText(createText("3X Score",24,36));
    addText(createText("2X Score",86,27));

    addText(createText("SCORE: ",1,1));
    addText(createText("FUEL: ",2,2));
    score = addText(createText("0",7,1));
    fuel = addText(createText("1000",7,2));

    mainLoop();

    return 0;
}
Exemplo n.º 24
0
void TrackDisplay::update(float wall_dt, float ros_dt) {
	V_TrackMsg local_queue;

	{
		boost::mutex::scoped_lock lock(queue_mutex_);

		local_queue.swap(message_queue_);
	}

	for (size_t t = 0; t < local_queue.size(); t++) {
		const articulation_msgs::TrackMsg::ConstPtr& track_message =
				local_queue[t];

		for(size_t l=0;l<lines[track_message->id].size();l++)
			lines[track_message->id][l]->clear();
		recycleLines.insert(recycleLines.begin(),
				lines[track_message->id].begin(),
				lines[track_message->id].end());

		lines[track_message->id].clear();
	}

	for (size_t t = 0; t < local_queue.size(); t++) {
		const articulation_msgs::TrackMsg::ConstPtr& track_message =
				local_queue[t];

		btTransform framePose;
		btVector3 lineScale(lineWidth_, lineWidth_, lineWidth_);
		transform(track_message, framePose);

		int channel_w = -1;
		int channel_h = -1;
		for (size_t i = 0; i < track_message->channels.size(); i++) {
			if (track_message->channels[i].name == "width")
				channel_w = (int) i;
			if (track_message->channels[i].name == "height")
				channel_h = (int) i;
		}

		Ogre::Vector3 old_pos(0,0,0);
		for (size_t i = 0; i < track_message->pose.size(); i++) {
			const geometry_msgs::Pose& geo_pose = track_message->pose[i];

			btTransform rectangle_pose(btQuaternion(geo_pose.orientation.x,
					geo_pose.orientation.y, geo_pose.orientation.z,
					geo_pose.orientation.w), btVector3(geo_pose.position.x,
					geo_pose.position.y, geo_pose.position.z));

			Ogre::Vector3 pos, scale;
			Ogre::Quaternion orient;
			transform(framePose * rectangle_pose, lineScale, pos, orient, scale);

			btVector3 color(color_.r_, color_.g_, color_.b_);	// fixed color

			double f =track_message->id / 7.0;
			color = modifyColor( color,  trackColor_, f - floor(f) );
			color = modifyColor( color,  poseColor_, i / (double)track_message->pose.size() );

			if(displayStyle_ == ds_line) {
				if(i==0) old_pos = pos;
				createLine(pos, old_pos, scale,
						color,
						lines[track_message->id],false);
				old_pos = pos;
			} else
			if(displayStyle_ == ds_cross_line) {
				if(i==0) old_pos = pos;
				createLine(pos, old_pos, scale,
						color,
						lines[track_message->id],true);
				old_pos = pos;
			} else
			if(displayStyle_ == ds_axes) {
				createAxes(pos, orient, scale,
						color,
						lines[track_message->id]);
			} else
			if(displayStyle_ == ds_rectangle) {
				createRectangle(pos, orient, scale,
						channel_w==-1? lineWidth_*5 : track_message->channels[channel_w].values[i],
						channel_h==-1? lineWidth_*5 : track_message->channels[channel_h].values[i],
						color,
						lines[track_message->id]);
			}
		}
	}
}
Exemplo n.º 25
0
DigiSpeMeasuringPoint::Sample* DigiSpeMeasuringPoint::getSamplePoint(TiXmlElement* elem, bool create)
{
	const char* cTemp;
	double dTemp;

	Vector3 sample = getCoords(elem) + sampleRayStartOffset - calcOffset;
	float len = sample.length();

	Sample* newSample = new Sample();
	newSample->pairPartner = NULL;
	newSample->dir = sample.normalisedCopy();
	newSample->len = len;

	cTemp = elem->Attribute("name");
	if (cTemp)
	{
		if ((cTemp[0] != 0) && getSampleByName(cTemp, false))
			LogManager::getSingleton().logMessage("WARNING: DigiSpe: Sample name '" + string(cTemp) + "' used more than once!", LML_CRITICAL);
		newSample->name = cTemp;
	}

	if (elem->Attribute("spread", &dTemp))
		newSample->invspread = 1.0f / dTemp;
	else
		newSample->invspread = 1.0f;

	cTemp = elem->Attribute("mode");
	if (cTemp)
		newSample->flat = (cTemp == string("flat"));
	else
		newSample->flat = false;

	cTemp = elem->Attribute("normal");
	if (cTemp)
		newSample->normal = StringConverter::parseVector3(cTemp).normalisedCopy();
	else if (newSample->flat)
		newSample->normal = -newSample->dir;
	else
		newSample->normal = Vector3::ZERO;
	newSample->planeC = newSample->normal.dotProduct(newSample->dir * newSample->len + midPointF);

	// Create the sample point
	if (create)
		createSamplePoint(newSample);

	// Create connection, if specified
	cTemp = elem->Attribute("connect");
	if (cTemp)
	{
		Sample* partner = prevSample;
		const char* cPartner = elem->Attribute("connectTo");
		if (cPartner)
		{
			partner = getSampleByName(cPartner);
			if (!partner)
				return NULL;
		}
		
		if (cTemp == string("line"))
			createLine(newSample, partner);
		else if (cTemp == string("pair"))
		{
			newSample->pairPartner = partner;
			newSample->connectionCenter = createLine(newSample, partner, true);

			cTemp = elem->Attribute("prevPair");
			if (cTemp)
			{
				Sample* prevPairFirst = getSampleByName(cTemp);
				if (!cTemp)
					return NULL;

				createLine(newSample, prevPairFirst);
				createLine(partner, prevPairFirst->pairPartner);
				createLine(newSample->connectionCenter, prevPairFirst->connectionCenter);
			}
		}
		else
		{
			LogManager::getSingleton().logMessage("ERROR: DigiSpe: Wrong value '" + string(cTemp) + "' specified for a connect attribute!", LML_CRITICAL);
			return NULL;
		}
	}

	prevSample = newSample;
	return newSample;
}
Exemplo n.º 26
0
int main (int argc, const char **argv, const char **env) {
  Light *light = malloc(sizeof(Light));

  light->location = vectorCreate(0.0, 10.0, 10.0);
  light->color = vectorCreate(1.0, 1.0, 1.0);
  light->intensity = 1.0;

  Light **lights = calloc(3, sizeof(Light*));

  lights[0] = light;

  light = malloc(sizeof(Light));

  light->location = vectorCreate(0.0, 3.0, 10.0);
  light->color = vectorCreate(1.0, 0.4, 1.0);
  light->intensity = 1.0;

  lights[1] = light;

  Primitive **primitives = calloc(10,sizeof(Primitive *));

  primitives[0] = createSphere((vector){3.0, 7.0, 2.0}, 2.0);
  primitives[1] = createSphere((vector){0.0, 10.0, 1.9}, 1.9);
  primitives[2] = createPlane(vectorCreate(0.0, 0.0, 1.0), vectorCreate(0.0, 0.0, 0.0));

  primitives[0]->material = malloc(sizeof(Material));
  primitives[1]->material = malloc(sizeof(Material));
  primitives[2]->material = malloc(sizeof(Material));

  primitives[0]->material->color = vectorCreate(1.0, 1.0, 1.0);
  primitives[1]->material->color = vectorCreate(1.0, 1.0, 1.0);
  primitives[2]->material->color = vectorCreate(0.0, 0.7, 0.0);

  primitives[0]->material->specular = 0.7;
  primitives[1]->material->specular = 0.3;
  primitives[2]->material->specular = 0.0;

  primitives[0]->material->diffuse = 1.0;
  primitives[1]->material->diffuse = 0.5;
  primitives[2]->material->diffuse = 1.0;

  primitives[0]->material->reflection = 0.5;
  primitives[1]->material->reflection = 0.5;
  primitives[2]->material->reflection = 0.0;
  
  primitives[0]->material->refraction = 0.0;
  primitives[1]->material->refraction = 1.1;
  primitives[2]->material->refraction = 0.0;
  
  primitives[0]->material->transparency = 0.0;
  primitives[1]->material->transparency = 0.7;
  primitives[2]->material->transparency = 0.0;
  
  primitives[3] = createPlane(vectorCreate(0.0, -1.0, 0.0), vectorCreate(0.0, 15.0, 0.0));
  primitives[3]->material = malloc(sizeof(Material));
  
  primitives[3]->material->color = vectorCreate(0.3, 0.2, 7.0);
  
  primitives[3]->material->specular = 0.0;
  primitives[3]->material->diffuse  = 1.0;
  primitives[3]->material->reflection = 0.0;
  primitives[3]->material->refraction = 0.0;
  primitives[3]->material->transparency = 0.0;

  vector camera = vectorCreate(0.0, -5.0, 5.0);

  png_uint_32 height = HEIGHT, width = WIDTH;

  png_bytepp imageBuffer = malloc(sizeof(png_bytep) * height);
  for (png_uint_32 i = 0; i < height; i++) {
    imageBuffer[i] = malloc(sizeof(png_byte) * 3 * width);
    for (png_uint_32 j = 0; j < width * 3; j++) {
      imageBuffer[i][j] = 0;
    }
  }
  
  int x,y;

  for (y = 0; y < HEIGHT; y++) {
    
    for (x = 0; x < WIDTH; x++) {
      Line *ray = createLine(camera, x, y);

      vector color = rayTrace(ray, primitives, lights, 1.0);
      
      free(ray);
      
      if (color.x >= 1.0) color.x = 1.0;
      if (color.y >= 1.0) color.y = 1.0;
      if (color.z >= 1.0) color.z = 1.0;
      
      imageBuffer[y][x * 3] = color.x * 255;
      imageBuffer[y][x * 3 + 1] = color.y * 255;
      imageBuffer[y][x * 3 + 2] = color.z * 255;
    }
  
  }
  
  writePNG(imageBuffer, width, height, 0);
    
  for (png_uint_32 i = 0; i < height; i++) {
    free(imageBuffer[i]);
  }    
  free(imageBuffer);

  return 0;
}
Exemplo n.º 27
0
int main()
{
	Vector::numVectors = 0;
	Vector::degreeMode = true;
	Vector BLANKVECTOR;
	Vector a(22,45);
	a.setLine(createLine(a), BLANKVECTOR);
	Vector b(34, 60);
	b.setLine(createLine(b,a),a);
	Vector c = a+b;
	c.setLine(createLine(c), BLANKVECTOR);


	sf::Vector2i toggleLocation(200,50);
	sf::RectangleShape toggle((sf::Vector2f)toggleLocation);
	toggle.setFillColor(sf::Color::Yellow);
	sf::RenderWindow window(sf::VideoMode(xMax, yMax), "FUNSICZ");
	sf::Font font;
	if (!font.loadFromFile("tnr.ttf"))
		return EXIT_FAILURE;
	sf::Mouse mouse;
	// Start the `main loop
	bool toggleComponents = false;
	int i=0;
	while (window.isOpen())
	{
		// Process events
		sf::Event event;
		while (window.pollEvent(event))
		{
			// Close window : exit
			if (event.type == sf::Event::Closed)
				window.close();
			if(event.type==event.MouseButtonReleased && event.mouseButton.button == sf::Mouse::Left && V2i_inRange(sf::Mouse::getPosition(window), toggleLocation, 200, 50))
			{
				i++;
				std::cout << "dicks  " << i <<std::endl;
				if(toggleComponents)
					toggleComponents = false;
				else
					toggleComponents = true;
			}
			if(event.type==event.KeyReleased && event.key.code == sf::Keyboard::Escape)
				loadMenu();
		}
		// Clear screen
		window.clear();
		
		
		if(toggleComponents)
		{
			
			window.draw(a.getCXL());
			window.draw(a.getCYL());
			window.draw(b.getCXL());
			window.draw(b.getCYL());
			window.draw(c.getCXL());
			window.draw(c.getCYL());
		}
		window.draw(a.getLine());
		window.draw(b.getLine());
		window.draw(c.getLine());
		window.draw(toggle);
	
		// Draw the string
		//window.draw(text);
		
		//window.draw(b_line);
		// Update the window
		window.display();
	}

return EXIT_SUCCESS;
}
Exemplo n.º 28
0
 /* load the file, parse the text, add the elements */
bool Scene::loadFile (std::string filename) {
    std::ifstream fs;
    fs.open (filename);
    if (!fs.is_open ()) {
        fs.close ();
        return false;
    }

    clearScene();

    int vertNum = 0;
    int lineNum = 0;
    int angleNum = 0;
    int fanoNum = 0;

    Vertex * newVerts[1024];
    Line * newLines[1024];

    int vertIdx = 0;
    int lineIdx = 0;

    std::cout<< "Reading in file " << filename << std::endl;
    std::string line;
    while(std::getline(fs, line)){

      //line that includes data
      if(line.length() > 0 && (line.at(0) == 'V' || line.at(0) == 'v')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        float x, y, z;
        x = atof(token);
        token = strtok(NULL, " ,");
        y = atof(token);
        token = strtok(NULL, " ,");
        z = atof(token);

        if(vertIdx == 0)
          newVerts[vertIdx++] = addVertex3f(x, y, z, 1);
        else
          newVerts[vertIdx++] = addVertex3f(x, y, z, 0);
      }
      else if(line.length() > 0 && (line.at(0) == 'L' || line.at(0) == 'l')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        int v1, v2;
        v1 = atoi(token);
        token = strtok(NULL, " ,");
        v2 = atoi(token);

        newLines[lineIdx++] = createLine(newVerts[v1], newVerts[v2]);
      }
      else if(line.length() > 0 && (line.at(0) == 'A' || line.at(0) == 'a')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        int l1, l2;
        l1 = atoi(token);
        token = strtok(NULL, " ,");
        l2 = atoi(token);
        createAngle(newLines[l1], newLines[l2]);
      }
      else if(line.length() > 0 && (line.at(0) == 'F' || line.at(0) == 'f')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        int a1, a2, a3;
        a1 = atoi(token);
        token = strtok(NULL, " ,");
        a2 = atoi(token);
        token = strtok(NULL, " ,");
        a3 = atoi(token);
        createFano(newLines[a1], newLines[a2], newLines[a3]);
      }
      else if(line.length()>0 && (line.at(0)=='C' || line.at(0)=='c')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        int l;
        float r, g, b;
        l = atoi(token);
        token = strtok(NULL, " ,");
        r = atof(token);
        token = strtok(NULL, " ,");
        g = atof(token);
        token = strtok(NULL, " ,");
        b = atof(token);
        Line *a = newLines[l];
        a->setColor3f(r,g,b);
      }
      
    }

    //...
    return true;
}
Exemplo n.º 29
0
void JointManager::initFrames(std::vector<std::string> jointList)
{
	// Clear layout
	for (unsigned i = 0; i < jointViews.size(); i++)
		delete jointViews[i];
	
	jointViews.clear();

	// Init labels for joints
	QLabel *jointsLabel = new QLabel("Joint");
	jointsLabel->setAlignment(Qt::AlignCenter);
	
	QFont font = jointsLabel->font();
	font.setBold(true);
	jointsLabel->setFont(font);
	
	jointsLayout->addWidget(jointsLabel, 0, 1);
	
	this->createHeaderLabels(PosVelEffView::LEFT, 0);
	this->createHeaderLabels(PosVelEffView::RIGHT, 0);
	
	// Init joints
	int row = 1;
	int id = 0;
	
	findAndPutView(jointList, "head_pitch", "Head Pitch", row++, PosVelEffView::NO_PAIR, id++, false);
	findAndPutView(jointList, "neck_yaw", "Head Yaw", row++, PosVelEffView::NO_PAIR, id++, false);
	
	for(int i = 0; i < 3; i++) // gap between blocks
		jointsLayout->addWidget(createLine(), row, i); 
	row++;
	
	findAndPutView(jointList, "left_shoulder_pitch", "Shoulder Pitch",  row, PosVelEffView::LEFT, id++, false);
	findAndPutView(jointList, "right_shoulder_pitch", "Shoulder Pitch", row++, PosVelEffView::RIGHT, id++, false);
	findAndPutView(jointList, "left_shoulder_roll", "Shoulder Roll",   row, PosVelEffView::LEFT, id++, true);
	findAndPutView(jointList, "right_shoulder_roll", "Shoulder Roll",  row++, PosVelEffView::RIGHT, id++, true);
	
	findAndPutView(jointList, "left_elbow_pitch", "Elbow Pitch", row, PosVelEffView::LEFT, id++, false);
	findAndPutView(jointList, "right_elbow_pitch", "Elbow Pitch",row++, PosVelEffView::RIGHT, id++, false);
	
	for(int i = 0; i < 3; i++) // gap between blocks
		jointsLayout->addWidget(createLine(), row, i); 
	row++;
	
	findAndPutView(jointList, "left_hip_yaw", "Hip Yaw",    row, PosVelEffView::LEFT, id++, true);
	findAndPutView(jointList, "right_hip_yaw", "Hip Yaw",   row++, PosVelEffView::RIGHT, id++, true);
	findAndPutView(jointList, "left_hip_roll", "Hip Roll",   row, PosVelEffView::LEFT, id++, true);
	findAndPutView(jointList, "right_hip_roll", "Hip Roll",  row++, PosVelEffView::RIGHT, id++, true);
	findAndPutView(jointList, "left_hip_pitch", "Hip Pitch",  row, PosVelEffView::LEFT, id++, false);
	findAndPutView(jointList, "right_hip_pitch", "Hip Pitch", row++, PosVelEffView::RIGHT, id++, false);
	
	for(int i = 0; i < 3; i++) // gap between blocks
		jointsLayout->addWidget(createLine(), row, i); 
	row++;
	
	findAndPutView(jointList, "left_knee_pitch", "Knee Pitch", row, PosVelEffView::LEFT, id++, false);
	findAndPutView(jointList, "right_knee_pitch", "Knee Pitch",row++, PosVelEffView::RIGHT, id++, false);
	
	findAndPutView(jointList, "left_ankle_pitch", "Ankle Pitch",  row, PosVelEffView::LEFT, id++, false);
	findAndPutView(jointList, "right_ankle_pitch", "Ankle Pitch", row++, PosVelEffView::RIGHT, id++, false);
	findAndPutView(jointList, "left_ankle_roll", "Ankle Roll",   row, PosVelEffView::LEFT, id++, true);
	findAndPutView(jointList, "right_ankle_roll", "Ankle Roll",  row++, PosVelEffView::RIGHT, id++, true);
	
	jointsLayout->setMargin(0);
	jointsLayout->setSpacing(0);
	jointsLayout->setContentsMargins(0,0,0,0);
}
Exemplo n.º 30
0
Arquivo: Reader.c Projeto: denji/mdr
char * getHTML()
{
    bstring html = bfromcstr("<!DOCTYPE html>\n<html>\n");
    balloc(html, style_css_len);
    bcatcstr(html, "<head>");
    bcatcstr(html, "<title>mdr</title>");
    bcatcstr(html, "<style type='text/css'>");
    bcatcstr(html, (char *)style_css);
    bcatcstr(html, "</style>");
    bcatcstr(html, "</head>");
    bcatcstr(html, "<body>\n<table cellpadding='0'>\n");

    // Read from stdin
    bstring stdinContents = bread ((bNread) fread, stdin);
    if (stdinContents == NULL)
    {
        return "There was an error reading from stdin.";
    }

    // Split into lines
    struct bstrList * inputLines;
    if ((inputLines = bsplit(stdinContents, '\n')) != NULL)
    {

        // We are going to build a map showing which lines in the input belong
        // in which lines in the output and how they should be displayed. We'll
        // allocate the left and right maps to be big enough to each hold all
        // the input data, which is more than enough.
        lineData * lineMapL = malloc(inputLines->qty * sizeof(lineData));
        if (lineMapL == NULL)
        {
            free(lineMapL);
            printf("Memory allocation error.\n");
            exit(-1);
        }
        lineData * lineMapR = malloc(inputLines->qty * sizeof(lineData));
        if (lineMapR == NULL)
        {
            free(lineMapR);
            printf("Memory allocation error.\n");
            exit(-1);
        }
        int lineMapPosL = 0;
        int lineMapPosR = 0;

        int useL;
        int useR;
        enum lineType type;
        int padding;
        int lineNoL = 0;
        int lineNoR = 0;
        int firstInfoLine = TRUE;
        int startNewFileOk = TRUE;
        int startOldFileOk = TRUE;

        // Map input lines to their output column (left, right, or both)
        int i;
        for (i = 0; i < inputLines->qty; i++) {

            useL = 0;
            useR = 0;
            type = SHARED;
            padding = 1;

            if (startOldFileOk && stringStartsWith(inputLines->entry[i], "---"))
            {
                type = OLD_FILE;
                useL = 1;
                padding = 4;
                lineNoL = -1;
                lineNoR = -1;
                startOldFileOk = FALSE;
            }
            else if (startNewFileOk && stringStartsWith(inputLines->entry[i], "+++"))
            {
                type = NEW_FILE;
                useR = 1;
                padding = 4;
                lineNoL = -1;
                lineNoR = -1;
                startNewFileOk = FALSE;
            }
            else if (stringStartsWith(inputLines->entry[i], "@@"))
            {
                syncLineNumbers(inputLines->entry[i], &lineNoL, &lineNoR);
                if (firstInfoLine)
                {
                    // Don't print the info row but still increment the line
                    // numbers normally.
                    // TODO: Might be better to mark the row as the first and
                    // hide it with CSS instead of just not printing it.
                    lineNoL++;
                    lineNoR++;
                }
                else
                {
                    type = INFO;
                    useR = 1;
                    useL = 1;
                    padding = 1;
                }
                firstInfoLine = FALSE;
            }
            else if (bdata(inputLines->entry[i])[0] == '-')
            {
                type = OLD;
                useL = 1;
            }
            else if (bdata(inputLines->entry[i])[0] == '+')
            {
                type = NEW;
                useR = 1;
            }
            else if (bdata(inputLines->entry[i])[0] == ' ')
            {
                type = SHARED;
                useL = 1;
                useR = 1;
            }
            else
            {
                type = HEADER;
                lineNoL = 0;
                lineNoR = 0;
                firstInfoLine = TRUE;
                startNewFileOk = TRUE;
                startOldFileOk = TRUE;
            }

            // Balance.
            if (type == HEADER ||
                (type == SHARED && (useL || useR)) ||
                i == inputLines->qty - 1)
            {
                int difference = lineMapPosL - lineMapPosR;
                int j;

                if (difference > 0)
                {
                    for (j = 0; j < difference; j++)
                    {
                        lineMapR[lineMapPosR].type = EMPTY;
                        lineMapPosR++;
                    }
                }
                else if (difference < 0)
                {
                    for (j = 0; j < (difference * -1); j++)
                    {
                        lineMapL[lineMapPosL].type = EMPTY;
                        lineMapPosL++;
                    }
                }
            }

            if (useL)
            {
                lineMapL[lineMapPosL].inputPos = i;
                lineMapL[lineMapPosL].type = type;
                lineMapL[lineMapPosL].padding = padding;
                lineMapL[lineMapPosL].lineNo = lineNoL - 1;
                lineMapL[lineMapPosL].leadingSpaces = 0;
                lineMapPosL++;
                lineNoL++;
            }

            if (useR)
            {
                lineMapR[lineMapPosR].inputPos = i;
                lineMapR[lineMapPosR].type = type;
                lineMapR[lineMapPosR].padding = padding;
                lineMapR[lineMapPosR].lineNo = lineNoR - 1;
                lineMapR[lineMapPosR].leadingSpaces = 0;
                lineMapPosR++;
                lineNoR++;
            }

        }

        // Mapping complete. Quick sanity check that both L and R cols have the
        // same length.
        if (lineMapPosL != lineMapPosR)
        {
            return "Error displaying diff (generated columns not equal in length).";
        }

        // Now we do the formatting work based on the map.
        for (i = 0; i < lineMapPosL; i++)
        {
            int * highlightMaskA = NULL;
            int * highlightMaskB = NULL;
            bstring contentL;
            bstring contentR;
            int leadingSpacesL = 0;
            int leadingSpacesR = 0;

            if (lineMapL[i].type != EMPTY)
            {
                contentL = getContentFromLine(
                    inputLines->entry[lineMapL[i].inputPos],
                    lineMapL[i].padding,
                    &leadingSpacesL
                );
                lineMapL[i].leadingSpaces = leadingSpacesL;
            }

            if (lineMapR[i].type != EMPTY)
            {
                contentR = getContentFromLine(
                    inputLines->entry[lineMapR[i].inputPos],
                    lineMapR[i].padding,
                    &leadingSpacesR
                );
                lineMapR[i].leadingSpaces = leadingSpacesR;
            }

            // Compare changed lines
            if (lineMapL[i].type == OLD && lineMapR[i].type == NEW) {

                lineMapL[i].type = CHANGE;
                lineMapR[i].type = CHANGE;

                determineLineHighlighting(
                    contentL,
                    contentR,
                    &highlightMaskA,
                    &highlightMaskB
                );

            }

            // Format output
            bcatcstr(html, "<tr>\n");

            if (lineMapL[i].type == EMPTY)
            {
                createEmptyLine(html);
            }
            else
            {
                createLine(LEFT, html, contentL, lineMapL[i], highlightMaskA);
                bdestroy(contentL);
            }

            if (lineMapR[i].type == EMPTY)
            {
                createEmptyLine(html);
            }
            else
            {
                createLine(RIGHT, html, contentR, lineMapR[i], highlightMaskB);
                bdestroy(contentR);
            }

            bcatcstr(html, "</tr>\n");

            free(highlightMaskA);
            free(highlightMaskB);
        }

        bcatcstr(html, "</table>\n</body>\n</html>\n");

        free(lineMapL);
        free(lineMapR);
    }

    bdestroy(stdinContents);
    bstrListDestroy(inputLines);

    char * result = bstr2cstr(html, '-');
    bdestroy(html);

    return result; // Caller should free()
}