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

Fixing ball radius and resolution when used to represent a 3D point #978

Merged
merged 5 commits into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from 2 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: 4 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@
and Viewer3D: no more "createNew...List" when setting a new
color. (David Coeurjolly,
[#958](https://github.com/DGtal-team/DGtal/pull/958))

- Radius and resolution of balls have been fixed when used to
represent a 3D point in grid mode (David Coeurjolly,
[#978](https://github.com/DGtal-team/DGtal/pull/978))


# DGtal 0.8

Expand Down
6 changes: 3 additions & 3 deletions src/DGtal/io/Display3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ namespace DGtal
RealPoint center;
bool isSigned;
bool signPos;
double size;
double radius;
unsigned int resolution;
};

Expand Down Expand Up @@ -622,12 +622,12 @@ namespace DGtal
/**
* Method to add a point to the current display.
* @param center ball center x
* @param size the ball radius (default 1)
* @param radius the ball radius (default 0.5)
* @param resolution ball resolution (default 30)
*
*/
void addBall(const RealPoint &center ,
const double size=1.0,
const double radius=0.5,
const unsigned int resolution = 30);


Expand Down
4 changes: 2 additions & 2 deletions src/DGtal/io/Display3D.ih
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ template < typename Space ,typename KSpace >
inline
void
DGtal::Display3D< Space ,KSpace >::addBall(const RealPoint &center,
const double size,
const double radius,
const unsigned int resolution)
{
updateBoundingBox(center);
Expand All @@ -295,7 +295,7 @@ DGtal::Display3D< Space ,KSpace >::addBall(const RealPoint &center,
p.color = getFillColor();
p.isSigned = false;
p.signPos = false;
p.size = size;
p.radius = radius;
p.resolution = resolution;
p.name = name3d();
if (myBallSetList.size()== 0)
Expand Down
7 changes: 6 additions & 1 deletion src/DGtal/io/Display3DFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ namespace DGtal
struct Display3DFactory
{

///The size of the ball radius when used to display a 3D point.
constexpr BOOST_STATIC_CONSTANT(double, POINT_AS_BALL_RADIUS = 0.1);
///The ball resolution when used to display a point
constexpr BOOST_STATIC_CONSTANT(unsigned int, POINT_AS_BALL_RES = 10);

typedef TSpace Space;
typedef TKSpace KSpace;
typedef Display3DFactory<Space, KSpace> Self;
Expand Down Expand Up @@ -624,7 +629,7 @@ namespace DGtal
*/
static void
draw( Display & display, const DGtal::SetSelectCallback3D& aFct );

}; // end of struct Display3DFactory

} // namespace DGtal
Expand Down
12 changes: 6 additions & 6 deletions src/DGtal/io/Display3DFactory.ih
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ void DGtal::Display3DFactory<Space,KSpace>::drawAsGrid( Display & display,
++it )
{
DGtal::Z3i::RealPoint rp = display.embed((*it) );
display.addBall(rp);
display.addBall(rp,POINT_AS_BALL_RADIUS, POINT_AS_BALL_RES);
}
}

Expand Down Expand Up @@ -587,7 +587,7 @@ void DGtal::Display3DFactory<Space,KSpace>::drawAsGrid( Display & display,
++it )
{
DGtal::Z3i::RealPoint rp = display.embed((*it) );
display.addBall(rp);
display.addBall(rp,POINT_AS_BALL_RADIUS, POINT_AS_BALL_RES);
}
}

Expand Down Expand Up @@ -833,7 +833,7 @@ void DGtal::Display3DFactory<Space,KSpace>::drawAsPavingBalls( Display & display
{
DGtal::Z3i::RealPoint rp = display.embed( DGtal::Z3i::Point(x, y, z) );
display.setFillColor(DGtal::Color(255, 0 ,0));
display.addBall(rp);
display.addBall(rp,POINT_AS_BALL_RADIUS, POINT_AS_BALL_RES);
}
}
}
Expand Down Expand Up @@ -981,7 +981,7 @@ void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
display.setFillColor(DGtal::Color(200, 200, 20, 255));
}

display.addBall(rp, 0.05);
display.addBall(rp, POINT_AS_BALL_RADIUS, POINT_AS_BALL_RES);
break;
case 1:
if(mode!=""&& mode!="Basic" && mode!="IllustrationCustomColor")
Expand Down Expand Up @@ -1121,7 +1121,7 @@ void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
else
display.setFillColor(DGtal::Color(20, 20, 150, 255));
}
display.addBall(rps, 0.05);
display.addBall(rps, POINT_AS_BALL_RADIUS, POINT_AS_BALL_RES);
break;
case 1:
if(mode!="" && mode!="Basic" && mode!="IllustrationCustomColor")
Expand Down Expand Up @@ -1245,7 +1245,7 @@ void DGtal::Display3DFactory<Space,KSpace>::drawAsGrid( Display & display,
ASSERT(dim == 3);
DGtal::Z3i::RealPoint rp = display.embed( p );
display.setFillColor(display.getLineColor());
display.addBall( rp);
display.addBall(rp,POINT_AS_BALL_RADIUS, POINT_AS_BALL_RES);
display.setFillColor(fillColorSave);
}

Expand Down
2 changes: 1 addition & 1 deletion src/DGtal/io/boards/Board3D.ih
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void DGtal::Board3D<Space, KSpace>::saveOBJ(const std::string & filename, const
double phiResolution = s_it->resolution;
double phiStep= M_PI/phiResolution;

double radius = s_it->size*scale;
double radius = s_it->radius*scale;
double xCenter = (s_it->center[0]-shift[0])*scale;
double yCenter = (s_it->center[1]-shift[0])*scale;
double zCenter = (s_it->center[2]-shift[0])*scale;
Expand Down
2 changes: 1 addition & 1 deletion src/DGtal/io/viewers/Viewer3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace DGtal
}


/// the 3 possible axes for the image direction
/// the 3 possible axes for the imaball3Dge direction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something wrong with your editor ;)

enum ImageDirection {xDirection, yDirection, zDirection, undefDirection };
/// the modes of representation of an image
enum TextureMode {RGBMode, GrayScaleMode };
Expand Down
4 changes: 2 additions & 2 deletions src/DGtal/io/viewers/Viewer3D.ih
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ DGtal::Viewer3D<Space, KSpace>::draw()
{
if ( Viewer3D<Space, KSpace>::myBallSetList.at ( j ).size() !=0 )
{
glPointSize ( ( Viewer3D<Space, KSpace>::myBallSetList.at ( j ).at ( 0 ).size ) /distCam );
glPointSize ( ( Viewer3D<Space, KSpace>::myBallSetList.at ( j ).at ( 0 ).radius ) /distCam );
}
glCallList(myBallSetListId+j);
}
Expand Down Expand Up @@ -1100,7 +1100,7 @@ DGtal::Viewer3D<Space, KSpace>::glDrawGLBall ( typename Viewer3D<Space, KSpace>:
double phiResolution = aBall.resolution;
double phiStep= M_PI/phiResolution;

double radius = aBall.size;
double radius = aBall.radius;
double xCenter = aBall.center[0];
double yCenter = aBall.center[1];
double zCenter = aBall.center[2];
Expand Down