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

ENH: Improve reconstruction order of vertices to change normals orientation #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ if(NOT COMMAND SETIFEMPTY)
endif()

#-----------------------------------------------------------------------------
SETIFEMPTY(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PRIMARY_PROJECT_NAME}-build/lib)
SETIFEMPTY(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PRIMARY_PROJECT_NAME}-build/lib)
SETIFEMPTY(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PRIMARY_PROJECT_NAME}-build/bin)
SETIFEMPTY(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PRIMARY_PROJECT_NAME}build/lib)
SETIFEMPTY(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PRIMARY_PROJECT_NAME}build/lib)
SETIFEMPTY(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PRIMARY_PROJECT_NAME}build/bin)

#-----------------------------------------------------------------------------
SETIFEMPTY(CMAKE_INSTALL_LIBRARY_DESTINATION lib)
Expand Down
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Surface Remesh

## Description

Surface reconstruction from rotated spheres (after RigidAlignment) or from coefficients (after GROUPS).


## Build

#### Requirements

Building SurfRemesh requires to have built previously:

* MeshLib (https://github.com/pdedumast/MeshLib)
* SlicerExecutionModel

SurfRemesh can either be built from GROUPS SuperBuild.


###### Linux or MacOSX

Consider this tree of repertories:
```
~/Project/SurfRemesh
/SurfRemesh-build
```

Start a terminal.
First change your current working directory to the build directory ```SurfRemesh-build```
```
cd ~/Project/SurfRemesh-build
```

Generate the project using ```cmake```
```
cmake -DMeshLib_DIR:PATH=path/to/MeshLib -DSlicerExecutionModel:PATH=path/to/SlicerExecutionModel ../SurfRemesh
make
```


## Usage

Reconstruction from new rotated sphere, after RigidAlignment:
Output surface will have the same parametrization with one specified by the reference sphere.
```
./SurfRemesh --input [<std::string> input surface model] --tempModel [<std::string> rotate sphere]
--ref [<std::string> common sphere model (same as refSphere in RigidAlignment)]
--output [<std::string> reconstructed surface]
```

Reconstruction from coefficients, after GROUPS:
```
./SurfRemesh --input [<std::string> input surface model] --tempModel [<std::string> sphere model used in GROUPS]
--ref [<std::string> common sphere model] --coeff [<std::string> Coefficients file from GROUPS]
--output [<std::string> reconstructed surface]
```

## Licence

See LICENSE.txt for information on using and contributing.
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_library(SurfRemesh
STATIC
SurfaceRemeshing.cpp)
SurfaceRemeshing.cpp)

11 changes: 7 additions & 4 deletions src/SurfaceRemeshing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ SurfaceRemeshing::SurfaceRemeshing(const char *subject, const char *sphere, cons
m_coeff[0] = 0;
m_coeff[1] = 0;
}

float phi, theta;
Coordinate::cart2sph(m_pole, &phi, &theta);

Expand Down Expand Up @@ -137,7 +138,7 @@ SurfaceRemeshing::SurfaceRemeshing(const char *subject, const char *sphere, cons
if (fabs(phi - phi_) < eps && fabs(theta - theta_) < eps) continue;
SphericalHarmonics::basis(m_degree, (float *)v->fv(), Y);
reconsCoord(v->fv(), v1, Y, m_coeff, m_degree, m_pole);
MathVector V(v1); V.unit();
MathVector V(v1); V.unit();
v->setVertex(V.fv());
}
}
Expand Down Expand Up @@ -194,6 +195,7 @@ SurfaceRemeshing::SurfaceRemeshing(const char *subject, const char *sphere, cons
}
}


void SurfaceRemeshing::reconsCoord(const float *v0, float *v1, float *Y, float *coeff, int degree, float *pole)
{
// spharm basis
Expand Down Expand Up @@ -244,8 +246,8 @@ void SurfaceRemeshing::reconsCoord(const float *v0, float *v1, float *Y, float *
// inverse rotation
Coordinate::rotPoint(rv, rot, v1);
}

/*void SurfaceRemeshing::reconsCoord(const float *v0, float *v1, float *Y, float *coeff, float degree, float *pole)
/*
void SurfaceRemeshing::reconsCoord(const float *v0, float *v1, float *Y, float *coeff, float degree, float *pole)
{
// spharm basis
int n = (degree + 1) * (degree + 1);
Expand Down Expand Up @@ -354,7 +356,7 @@ void SurfaceRemeshing::deformSurface()
d_v[0] = dataInterpolation(m_x, id, coeff, m_sphere_subj);
d_v[1] = dataInterpolation(m_y, id, coeff, m_sphere_subj);
d_v[2] = dataInterpolation(m_z, id, coeff, m_sphere_subj);

if (m_keepColor)
{
int *d_c = new int[3];
Expand All @@ -372,6 +374,7 @@ void SurfaceRemeshing::deformSurface()
d_v[2] = dataMedian(m_z, id, m_sphere_subj);
}
Vertex *new_v = (Vertex *)m_remesh->vertex(i);

new_v->setVertex(d_v);
}
}
Expand Down
4 changes: 2 additions & 2 deletions wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


if(UNIX)
set( INSTALL_RUNTIME_DESTINATION bin)
set( INSTALL_LIBRARY_DESTINATION lib)
Expand All @@ -20,4 +19,5 @@ SEMMacroBuildCLI(
INSTALL_ARCHIVE_DESTINATION ${INSTALL_ARCHIVE_DESTINATION}
)

install(TARGETS SRemesh RUNTIME DESTINATION ${INSTALL_RUNTIME_DESTINATION})
install(TARGETS SRemesh RUNTIME DESTINATION ${INSTALL_RUNTIME_DESTINATION})

2 changes: 2 additions & 0 deletions wrapper/SRemesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ int main(int argc, char* argv[])
{
PARSE_ARGS;

std::cout<<std::endl<<std::endl;

if (argc < 2)
{
std::cout << "Usage: " << argv[0] << " --help" << std::endl;
Expand Down