Skip to content

Commit

Permalink
still some work to do with links and union
Browse files Browse the repository at this point in the history
  • Loading branch information
avalero committed Nov 26, 2012
1 parent 34bb859 commit c98aafc
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 38 deletions.
13 changes: 13 additions & 0 deletions src/core/RotMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
#include "RotMatrix.h"
#include "Math.h"

RotationalMatrix RotationalMatrix::getInv() const{
RotationalMatrix inv;

//Inverse of RotMatrix is its traspose
for (int i=1;i<=3;i++){
for (int j=1;j<=3;j++){
inv.set(i,j,get(j,i));
}
}

return inv;
}

RotationalMatrix& RotationalMatrix::operator *(RotationalMatrix const & matrix){
RotationalMatrix* result = new RotationalMatrix();

Expand Down
2 changes: 2 additions & 0 deletions src/core/RotMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class OOMLCore_EXP_DEC RotationalMatrix: public Matrix<double,3,3>
*/
void getGlobalXYZAngles(double &x, double &y, double &z);

RotationalMatrix getInv() const;

};

#endif // REFSYS_H_INCLUDED
2 changes: 1 addition & 1 deletion src/core/TransformDecorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OOMLCore_EXP_DEC TransformDecorator : public ObjectDecorator

TransformMatrix tr2 = transform->_tr;

//if there are untransformed links apply before transforming
//if there are links apply inverse of transformation before transforming
Links lks = transform->AbstractObject::getLinks();
for (int i=0;i<lks.size();i++){
RefSys lk = lks[i];
Expand Down
44 changes: 20 additions & 24 deletions src/core/Union.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,34 @@
#include <iostream>

Links Union::getLinks() const {
std::cout << "I am here" << std::endl;
Links lks1;

if (hasLinks()){ //If the Union Component has links return all its links and all the children links
Links lks1 = AbstractObject::getLinks();
Links lks2 = _children[0]->getLinks();
lks1 = AbstractObject::getLinks();
}

for (int j=0;j<_children.size();j++){
Links lks2 = _children[j]->getLinks();
lks1.insert( lks1.end(), lks2.begin(), lks2.end() );
return lks1;
}else{ //Return all the children links
Links lks1;
for (int j=0;j<_children.size();j++){
Links lks2 = _children[0]->getLinks();
lks1.insert( lks1.end(), lks2.begin(), lks2.end() );
}
return lks1;
}

return lks1;
}

RefSys Union::getLink(int i) const {
if (hasLinks()){ //If the Union Component has links consider all its links and all the children links
Links lks1 = AbstractObject::getLinks();
for (int j=0;j<_children.size();j++){
Links lks2 = _children[0]->getLinks();
lks1.insert( lks1.end(), lks2.begin(), lks2.end() );
}
return lks1[i];
Links lks1, lks2;

}else{ //Consider all the children links
Links lks1;
for (int j=0;j<_children.size();j++){
Links lks2 = _children[0]->getLinks();
lks1.insert( lks1.end(), lks2.begin(), lks2.end() );
}
return lks1[i];
if (hasLinks()){ //If the Union Component has links return all its links and all the children links
lks1 = AbstractObject::getLinks();
}

for (int j=0;j<_children.size();j++){
lks2 = _children[j]->getLinks();
lks1.insert( lks1.end(), lks2.begin(), lks2.end() );
}

return lks1[i];
}


Expand Down
8 changes: 0 additions & 8 deletions src/parts/ArduinoUNO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ Component ArduinoUNO::getBoard(double height, double holes_height, bool fill_hol
else
board = prism1 + prism2 - holes;

//Add one link at each drill
board.addLink(RefSys(13.97,2.54,0));
board.addLink(RefSys(66.04,7.62,0));
board.addLink(RefSys(66.04,35.56,0));
board.addLink(RefSys(15.24,50.8,0));



return board.color(0,0,1);
}

Expand Down
4 changes: 4 additions & 0 deletions src/parts/ArduinoUNO.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class OOMLParts_EXP_DEC ArduinoUNO : public AbstractPart
_fourth_drill(fourth_hole)
{
rebuild();
addLink(RefSys(13.97,2.54,0));
addLink(RefSys(66.04,7.62,0));
addLink(RefSys(66.04,35.56,0));
addLink(RefSys(15.24,50.8,0));
}
/**
* \brief Default destructor.
Expand Down
23 changes: 18 additions & 5 deletions test/attachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,29 @@ int main(int argc, char **argv)

//Component cyl = Cylinder(3,50);

cube1.translate(5,0,0);
//cube1.translate(5,0,0);

cube1.addLink(RefSys(0,0,0));

cube1.translate(5,0,0);
cube1.rotate(0,0,45);
Component cube2 = Cube(3,50,2);
cube2.addLink(RefSys(1.5,25,1.5));

//cube1.translate(5,0,0);
//cube1.rotate(0,0,45);

Component ardu = ArduinoUNO();

Component wheel = SharpIRSensor();

wheel.addLink(RefSys(10,10,10));

Component comp = ardu + cube1;

//comp.addLink(RefSys(20,20,20));

/* Generate OpenSCAD code and write to file */
writer << LinksView(cube1);
writer << cube1;
writer << LinksView(comp);
writer << comp;
file << writer ;
file.close();
std::cout << "Done" << std::endl;
Expand Down

0 comments on commit c98aafc

Please sign in to comment.