35 #ifndef AIMS_DISTANCEMAP_PROJECTION_H
36 #define AIMS_DISTANCEMAP_PROJECTION_H
55 namespace meshdistance
69 float alpha,
float dmin,
71 const std::map <short,std::string> & trans,
72 const std::set<std::string> & labels,
73 float maxdil,
float maxdil_mesh,
float alpha_reg,
75 const std::vector<std::list<unsigned> > & neigho);
82 float demin,
float dpmin,
84 const std::map <short,std::string> & trans,
85 const std::set<std::string> & labels,
86 float maxdil,
float maxdil_mesh,
float alpha_reg,
88 const std::vector<std::list<unsigned> > & neigho);
96 std::set<short> &cc_sulci_labels,
97 std::map<short,short > &tri_sulci,
98 std::map<unsigned, Point3dfSet > &cc_sulci_coord,
102 float alpha,
float dmin);
109 std::set<short> &cc_sulci_labels,
110 std::map<short,short > &tri_sulci,
113 std::map<unsigned, Point3dfSet > &cc_sulci_coord,
114 std::map<Point3df, Point3df, Point3dfCompare > &initend,
115 float demin,
float dpmin,
116 short label_insula_left,
short label_insula_right,
122 const std::map<Point3df, Point3df, Point3dfCompare >
126 float dmin,
float alpha_reg );
148 short label,
const unsigned size_neigh,
149 unsigned max_points = 50);
160 std::pair<Point3df,Point3df> output;
161 unsigned inc = 0, i=0,j=0,n = init_point.size();
165 carto::AllocatorContext::fast() );
166 Point3dfSet::const_iterator is,es;
168 for (is = init_point.begin(), es = init_point.end(); is != es; ++is)
171 mean = mean / (float)n;
173 for (is = init_point.begin(), es = init_point.end(); is != es; ++is,
175 norm_point.insert(*is - mean);
178 for (is = norm_point.begin(), es = norm_point.end(); is != es; ++is,
184 cov(i,j) += temp[i] * temp[j];
189 eigen.
sort(cov,value);
196 output.second = temp;
206 unsigned inc = 0, i=0,j=0;
210 carto::AllocatorContext::fast() );
211 Point3dfSet::const_iterator is,es;
213 for( is = init_point.begin(), es = init_point.end(); is != es;
215 norm_point.insert(*is - pt);
218 for( is = norm_point.begin(), es = norm_point.end(); is != es;
224 cov(i,j) += temp[i] * temp[j];
229 eigen.
sort(cov,value);
244 C[0] = A[1] * B[2] - A[2] * B[1];
245 C[1] = A[2] * B[0] - A[0] * B[2];
246 C[2] = A[0] * B[1] - A[1] * B[0];
266 Point3df pt_intersection, normal_tri;
270 normal_tri =
cross(s1 - s2,s1 - s3);
284 a = direction_line[0];
285 b = direction_line[1];
286 c = direction_line[2];
293 pt_intersection[0] = (c * c0 * xm +
300 ( c * c0 + a * a0 + b0 * b);
303 pt_intersection[1] = ( b * c0 * zb +
310 (c * c0 + a * a0 + b0 * b);
312 pt_intersection[2] = ( c * c0 * zb
319 (c * c0 + a * a0 + b0 * b);
321 return (pt_intersection);
333 d = fabs( temp.
dot(plane.second) );
362 Point3dfNeigh::const_iterator is,es = neigh.
end();
363 std::vector<Point3df>::const_iterator icc,ecc = cc.end();
367 while (!ok1 && icc != ecc)
370 is = neigh.find(PtR);
373 if (is->second.size() > MIN_NEIGH)
380 std::cerr <<
"Pb1: cannot find the neighbours of the point "
386 for(icc = cc.begin(); icc != ecc; ++icc)
389 is = neigh.find(PtR);
392 if (is->second.size() > MIN_NEIGH)
396 std::cerr <<
"Pb2: cannot find the neighbours of the point "
398 normal_plan *= normal_plan.
dot(n1);
399 normal_plan.normalize();
404 std::cout <<
"CC mean normal : "<< n0 << std::endl;
void sort(carto::VolumeRef< T > eigenvectors, carto::VolumeRef< T > eigenvalues, carto::VolumeRef< T > *wi=NULL)
Sort the eigenvectors and eigenvalues in decreasing order.
carto::VolumeRef< T > doit(carto::VolumeRef< T >, carto::VolumeRef< T > *wi=NULL)
Eigen system resolution function.
AimsVector< T, D > & normalize()
T dot(const AimsVector< T, D > &other) const
float DistancePointToLine(const Point3df &A, const std::pair< Point3df, Point3df > &line)
Texture< short > VolumeParcellation2MeshParcellation(const carto::rc_ptr< carto::Volume< short > > &initVol, const AimsSurface< 3, Void > &mesh, short back)
const short MESHDISTANCE_UNREACHED
std::pair< Point3df, Point3df > NormalFromPoints(const Point3dfSet &init_point)
carto::VolumeRef< short > MeshParcellation2Volume(const carto::rc_ptr< carto::Volume< short > > &initVol, const Texture< short > &tex, const AimsSurface< 3, Void > &mesh, short val_domain, short back)
Texture< short > FirstSulciProjectionWithCurvatureMap(const carto::rc_ptr< carto::Volume< short > > &ccvol, const carto::rc_ptr< carto::Volume< short > > &sulcvol, const AimsSurface< 3, Void > &mesh, std::set< short > &cc_sulci_labels, std::map< short, short > &tri_sulci, std::map< unsigned, Point3dfSet > &cc_sulci_coord, std::map< Point3df, Point3df, Point3dfCompare > &initend, const Texture< float > &curvtex, float alpha, float dmin)
Point3df IntersectionPointOfPlanAndLine(const Point3df &s1, const Point3df &s2, const Point3df &s3, const Point3df &direction_line, const Point3df &pt)
void NeighbourInCC(std::map< Point3df, Point3dfSet, Point3dfCompare > &neigh, const carto::rc_ptr< carto::Volume< short > > &bvol, const carto::rc_ptr< carto::Volume< short > > &svol, Connectivity::Type connectivity, short label, const unsigned size_neigh, unsigned max_points=50)
Give the neighbours of a point The neighbours have the same label as the point.
Point3df cross(const Point3df &A, const Point3df &B)
TimeTexture< short > SulcusVolume2Texture(const AimsSurface< 3, Void > &mesh, const Texture< float > &curvtex, const carto::rc_ptr< carto::Volume< short > > &bottom_vol, const carto::rc_ptr< carto::Volume< short > > &surface_vol, float alpha, float dmin, int MINCC, const std::map< short, std::string > &trans, const std::set< std::string > &labels, float maxdil, float maxdil_mesh, float alpha_reg, bool connexity, const std::vector< std::list< unsigned > > &neigho)
Projection of the voxels relative to the bottom of the sulci to the edges of a triangulation.
void AffinePointProjection(Texture< short > &tex, const AimsSurface< 3, Void > &mesh, const std::map< Point3df, Point3df, Point3dfCompare > &initend, const Point3dfSet &setpointi, short label, float dmin, float alpha_reg)
Texture< short > FirstSulciProjectionWithInterpolationPlane(const carto::rc_ptr< carto::Volume< short > > &ccvol, const carto::rc_ptr< carto::Volume< short > > &sulcvol, const AimsSurface< 3, Void > &mesh, std::set< short > &cc_sulci_labels, std::map< short, short > &tri_sulci, const std::map< Point3df, Point3dfSet, Point3dfCompare > &neigh, std::map< unsigned, Point3dfSet > &cc_sulci_coord, std::map< Point3df, Point3df, Point3dfCompare > &initend, float demin, float dpmin, short label_insula_left, short label_insula_right, const Point3df &CA)
float DistancePointToPlane(const Point3df &A, const std::pair< Point3df, Point3df > &plane)
const short MESHDISTANCE_FORBIDDEN
global variable...
Point3df meanNormalofCC(const std::vector< Point3df > &cc, const Point3dfNeigh &neigh, unsigned MIN_NEIGH)
std::set< Point3df, Point3dfCompare > Point3dfSet
std::map< Point3df, Point3dfSet, Point3dfCompare > Point3dfNeigh