Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trcl translation fix #41

Merged
merged 2 commits into from
Jul 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions geometry.cpp
Original file line number Diff line number Diff line change
@@ -19,6 +19,11 @@ double matrix_det( double mat[9] ){
mat[2]*mat[4]*mat[6]);
}

void Transform::modify_translation( const Vector3d& translation_addition ) {
translation = translation + translation_addition;
return;
}

/**
* Compute Euler axis/angle, given a rotation matix.
* See en.wikipedia.org/wiki/Rotation_representation_(mathematics)
16 changes: 16 additions & 0 deletions geometry.hpp
Original file line number Diff line number Diff line change
@@ -43,6 +43,13 @@ class Vector3d{
v[2] = p.at(idx+2);
}


Vector3d( const Vector3d& other ) {
v[0] = other.v[0];
v[1] = other.v[1];
v[2] = other.v[2];
}

double length() const{
return sqrt( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
}
@@ -52,6 +59,13 @@ class Vector3d{
return Vector3d( v[0]/length, v[1]/length, v[2]/length );
}

Vector3d& operator=( const Vector3d& other) {
v[0] = other.v[0];
v[1] = other.v[1];
v[2] = other.v[2];
return *this;
}

Vector3d operator-() const {
return Vector3d(-v[0], -v[1], -v[2]);
}
@@ -131,6 +145,8 @@ class Transform{
Transform( double rot[9], const Vector3d& trans, enum mat_format = C_STYLE );

const Vector3d& getTranslation() const { return translation; }
void modify_translation( const Vector3d& translation_addition );
void modify_translation( const Vector3d& translation_addition ) const;
bool hasRot() const{ return has_rot; }
bool hasInversion() const{ return invert; }
double getTheta() const { return theta; }
20 changes: 19 additions & 1 deletion mcnp2cad.cpp
Original file line number Diff line number Diff line change
@@ -1061,10 +1061,28 @@ bool GeometryContext::defineLatticeNode( CellCard& cell, iBase_EntityHandle cel
else{
// this node has an embedded universe

const Transform* trans = NULL;

if( fn->hasTransform() ) {
trans = &(fn->getTransform());
}

// check for parent cell transformation
if( cell.getTrcl().hasData() ) {
Transform trcl = cell.getTrcl().getData();
if( trans ) {
Vector3d temp = trcl.getTranslation();
trans->modify_translation( temp );
}
else {
trans = &(trcl);
}
}

iBase_EntityHandle cell_copy_unmoved;
iGeom_copyEnt( igm, cell_shell, &cell_copy_unmoved, &igm_result );
CHECK_IGEOM( igm_result, "Re-copying a lattice cell shell" );
node_subcells = defineUniverse( fn->getFillingUniverse(), cell_copy_unmoved, (fn->hasTransform() ? &(fn->getTransform()) : NULL ) );
node_subcells = defineUniverse( fn->getFillingUniverse(), cell_copy_unmoved, trans );
for( size_t i = 0; i < node_subcells.size(); ++i ){
node_subcells[i] = applyTransform( t, igm, node_subcells[i] );
}