Changeset c15ca2
- Timestamp:
- Dec 29, 2009, 2:48:49 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 97498a
- Parents:
- 71b20e
- Location:
- src
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_correlation.cpp
r71b20e rc15ca2 267 267 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 268 268 if ((type == NULL) || (Walker->type == type)) { 269 triangle = Surface->FindClosestTriangleTo Point(Walker->node, LC );269 triangle = Surface->FindClosestTriangleToVector(Walker->node, LC ); 270 270 if (triangle != NULL) { 271 271 distance = DistanceToTrianglePlane(Walker->node, triangle); … … 327 327 checkX.AddVector(&periodicX); 328 328 checkX.MatrixMultiplication(FullMatrix); 329 triangle = Surface->FindClosestTriangleTo Point(&checkX, LC );329 triangle = Surface->FindClosestTriangleToVector(&checkX, LC ); 330 330 if (triangle != NULL) { 331 331 distance = DistanceToTrianglePlane(&checkX, triangle); -
src/tesselation.cpp
r71b20e rc15ca2 1423 1423 TesselPoint *Walker = NULL; 1424 1424 Vector *Center = cloud->GetCenter(); 1425 list<BoundaryTriangleSet*>*triangles = NULL;1425 TriangleList *triangles = NULL; 1426 1426 bool AddFlag = false; 1427 1427 LinkedCell *BoundaryPoints = NULL; … … 1438 1438 Log() << Verbose(0) << "Current point is " << *Walker << "." << endl; 1439 1439 // get the next triangle 1440 triangles = FindClosestTrianglesTo Point(Walker->node, BoundaryPoints);1440 triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints); 1441 1441 BTS = triangles->front(); 1442 1442 if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) { … … 2339 2339 2340 2340 // fill the set of neighbours 2341 Center.CopyVector(CandidateLine.BaseLine->endpoints[1]->node->node); 2342 Center.SubtractVector(TurningPoint->node); 2343 set<TesselPoint*> SetOfNeighbours; 2341 TesselPointSet SetOfNeighbours; 2344 2342 SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node); 2345 2343 for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++) 2346 2344 SetOfNeighbours.insert(*Runner); 2347 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, &Center);2345 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->node); 2348 2346 2349 2347 // go through all angle-sorted candidates (in degenerate n-nodes case we may have to add multiple triangles) 2348 Log() << Verbose(0) << "List of Candidates for Turning Point: " << *TurningPoint << "." << endl; 2349 for (TesselPointList::iterator TesselRunner = connectedClosestPoints->begin(); TesselRunner != connectedClosestPoints->end(); ++TesselRunner) 2350 Log() << Verbose(0) << **TesselRunner << endl; 2350 2351 TesselPointList::iterator Runner = connectedClosestPoints->begin(); 2351 2352 TesselPointList::iterator Sprinter = Runner; … … 2357 2358 AddTesselationPoint((*Sprinter), 2); 2358 2359 2359 2360 2360 // add the lines 2361 2361 AddTesselationLine(TPS[0], TPS[1], 0); … … 2374 2374 Runner = Sprinter; 2375 2375 Sprinter++; 2376 Log() << Verbose(0) << "Current Runner is " << **Runner << "." << endl; 2377 if (Sprinter != connectedClosestPoints->end()) 2378 Log() << Verbose(0) << " There are still more triangles to add." << endl; 2376 2379 } 2377 2380 delete(connectedClosestPoints); … … 2958 2961 const BoundaryLineSet * lines[2] = { line1, line2 }; 2959 2962 class BoundaryPointSet *node = NULL; 2960 map<int, class BoundaryPointSet *>OrderMap;2961 pair<map<int, class BoundaryPointSet *>::iterator, bool>OrderTest;2963 PointMap OrderMap; 2964 PointTestPair OrderTest; 2962 2965 for (int i = 0; i < 2; i++) 2963 2966 // for both lines … … 2979 2982 }; 2980 2983 2981 /** Finds the triangle that isclosest to a given Vector \a *x.2984 /** Finds the boundary points that are closest to a given Vector \a *x. 2982 2985 * \param *out output stream for debugging 2983 2986 * \param *x Vector to look from 2984 * \return list of BoundaryTriangleSet of nearest triangles or NULL in degenerate case.2985 */ 2986 list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint(const Vector *x, const LinkedCell* LC) const2987 { 2988 2987 * \return map of BoundaryPointSet of closest points sorted by squared distance or NULL. 2988 */ 2989 DistanceMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const 2990 { 2991 Info FunctionInfo(__func__); 2989 2992 PointMap::const_iterator FindPoint; 2990 2993 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; … … 3001 3004 Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl; 3002 3005 3003 set<BoundaryPointSet *> points;3006 DistanceMap * points = new DistanceMap; 3004 3007 LC->GetNeighbourBounds(Nlower, Nupper); 3005 3008 //Log() << Verbose(1) << endl; … … 3013 3016 FindPoint = PointsOnBoundary.find((*Runner)->nr); 3014 3017 if (FindPoint != PointsOnBoundary.end()) 3015 points .insert(FindPoint->second);3018 points->insert(DistancePair (FindPoint->second->node->node->DistanceSquared(x), FindPoint->second) ); 3016 3019 } 3017 3020 } else { … … 3021 3024 3022 3025 // check whether we found some points 3023 if (points.empty()) { 3024 Log() << Verbose(1) << "There is no nearest triangle, too far away from the surface." << endl; 3026 if (points->empty()) { 3027 eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl; 3028 delete(points); 3029 return NULL; 3030 } 3031 return points; 3032 }; 3033 3034 /** Finds the boundary line that is closest to a given Vector \a *x. 3035 * \param *out output stream for debugging 3036 * \param *x Vector to look from 3037 * \return closest BoundaryLineSet or NULL in degenerate case. 3038 */ 3039 BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const 3040 { 3041 Info FunctionInfo(__func__); 3042 3043 // get closest points 3044 DistanceMap * points = FindClosestBoundaryPointsToVector(x,LC); 3045 if (points == NULL) { 3046 eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl; 3025 3047 return NULL; 3026 3048 } … … 3033 3055 Vector Center; 3034 3056 Vector BaseLine; 3035 for ( set<BoundaryPointSet *>::iterator Runner = points.begin(); Runner != points.end(); Runner++) {3036 for (LineMap::iterator LineRunner = (*Runner)->lines.begin(); LineRunner != (*Runner)->lines.end(); LineRunner++) {3057 for (DistanceMap::iterator Runner = points->begin(); Runner != points->end(); Runner++) { 3058 for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) { 3037 3059 // calculate closest point on line to desired point 3038 3060 helper.CopyVector((LineRunner->second)->endpoints[0]->node->node); … … 3067 3089 } 3068 3090 } 3091 delete(points); 3069 3092 // check whether closest line is "too close" :), then it's inside 3070 3093 if (ClosestLine == NULL) { … … 3072 3095 return NULL; 3073 3096 } 3074 list<BoundaryTriangleSet*> *triangles = new list<BoundaryTriangleSet*>; 3097 return ClosestLine; 3098 }; 3099 3100 3101 /** Finds the triangle that is closest to a given Vector \a *x. 3102 * \param *out output stream for debugging 3103 * \param *x Vector to look from 3104 * \return BoundaryTriangleSet of nearest triangle or NULL. 3105 */ 3106 TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const 3107 { 3108 Info FunctionInfo(__func__); 3109 3110 // get closest points 3111 DistanceMap * points = FindClosestBoundaryPointsToVector(x,LC); 3112 if (points == NULL) { 3113 eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl; 3114 return NULL; 3115 } 3116 3117 // for each point, check its lines, remember closest 3118 Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl; 3119 BoundaryLineSet *ClosestLine = NULL; 3120 double MinDistance = -1.; 3121 Vector helper; 3122 Vector Center; 3123 Vector BaseLine; 3124 for (DistanceMap::iterator Runner = points->begin(); Runner != points->end(); Runner++) { 3125 for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) { 3126 for (TriangleMap::iterator TriangleRunner = LineRunner->second->triangles.begin(); TriangleRunner != LineRunner->second->triangles.end(); TriangleRunner++) { 3127 // calculate closest point on line to desired point 3128 helper.CopyVector((LineRunner->second)->endpoints[0]->node->node); 3129 helper.AddVector((LineRunner->second)->endpoints[1]->node->node); 3130 helper.Scale(0.5); 3131 Center.CopyVector(x); 3132 Center.SubtractVector(&helper); 3133 BaseLine.CopyVector((LineRunner->second)->endpoints[0]->node->node); 3134 BaseLine.SubtractVector((LineRunner->second)->endpoints[1]->node->node); 3135 Center.ProjectOntoPlane(&BaseLine); 3136 const double distance = Center.NormSquared(); 3137 if ((ClosestLine == NULL) || (distance < MinDistance)) { 3138 // additionally calculate intersection on line (whether it's on the line section or not) 3139 helper.CopyVector(x); 3140 helper.SubtractVector((LineRunner->second)->endpoints[0]->node->node); 3141 helper.SubtractVector(&Center); 3142 const double lengthA = helper.ScalarProduct(&BaseLine); 3143 helper.CopyVector(x); 3144 helper.SubtractVector((LineRunner->second)->endpoints[1]->node->node); 3145 helper.SubtractVector(&Center); 3146 const double lengthB = helper.ScalarProduct(&BaseLine); 3147 if (lengthB*lengthA < 0) { // if have different sign 3148 ClosestLine = LineRunner->second; 3149 MinDistance = distance; 3150 Log() << Verbose(1) << "ACCEPT: New closest line is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl; 3151 } else { 3152 Log() << Verbose(1) << "REJECT: Intersection is outside of the line section: " << lengthA << " and " << lengthB << "." << endl; 3153 } 3154 } else { 3155 Log() << Verbose(1) << "REJECT: Point is too further away than present line: " << distance << " >> " << MinDistance << "." << endl; 3156 } 3157 } 3158 } 3159 } 3160 delete(points); 3161 3162 // check whether closest line is "too close" :), then it's inside 3163 if (ClosestLine == NULL) { 3164 Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl; 3165 return NULL; 3166 } 3167 TriangleList * candidates = new TriangleList; 3075 3168 for (TriangleMap::iterator Runner = ClosestLine->triangles.begin(); Runner != ClosestLine->triangles.end(); Runner++) { 3076 triangles->push_back(Runner->second);3077 } 3078 return triangles;3169 candidates->push_back(Runner->second); 3170 } 3171 return candidates; 3079 3172 }; 3080 3173 … … 3085 3178 * \return list of BoundaryTriangleSet of nearest triangles or NULL. 3086 3179 */ 3087 class BoundaryTriangleSet * Tesselation::FindClosestTriangleTo Point(const Vector *x, const LinkedCell* LC) const3180 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const 3088 3181 { 3089 3182 Info FunctionInfo(__func__); 3090 3183 class BoundaryTriangleSet *result = NULL; 3091 list<BoundaryTriangleSet*> *triangles = FindClosestTrianglesToPoint(x, LC);3092 list<BoundaryTriangleSet*>candidates;3184 TriangleList *triangles = FindClosestTrianglesToVector(x, LC); 3185 TriangleList candidates; 3093 3186 Vector Center; 3094 3187 Vector helper; … … 3099 3192 // reject all which are not closest 3100 3193 double MinDistance = -1.; 3101 for ( list<BoundaryTriangleSet*>::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) {3194 for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) { 3102 3195 (*Runner)->GetCenter(&Center); 3103 3196 helper.CopyVector(x); … … 3149 3242 { 3150 3243 Info FunctionInfo(__func__); 3151 class BoundaryTriangleSet *result = FindClosestTriangleTo Point(&Point, LC);3244 class BoundaryTriangleSet *result = FindClosestTriangleToVector(&Point, LC); 3152 3245 Vector Center; 3153 3246 Vector helper; … … 3197 3290 } 3198 3291 3199 /**3200 * Finds the point which is second closest to the provided one.3201 *3202 * @param Point to which to find the second closest other point3203 * @param linked cell structure3204 *3205 * @return point which is second closest to the provided one3206 * @TODO Optimize me! These finds are unnecessary if we have a LC list of BoundaryPoints only!3207 */3208 TesselPoint* Tesselation::FindSecondClosestBoundaryPoint(const Vector* Point, const LinkedCell* const LC) const3209 {3210 Info FunctionInfo(__func__);3211 TesselPoint* closestPoint = NULL;3212 TesselPoint* secondClosestPoint = NULL;3213 double distance = 1e16;3214 double secondDistance = 1e16;3215 Vector helper;3216 int N[NDIM], Nlower[NDIM], Nupper[NDIM];3217 3218 LC->SetIndexToVector(Point); // ignore status as we calculate bounds below sensibly3219 for(int i=0;i<NDIM;i++) // store indices of this cell3220 N[i] = LC->n[i];3221 Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;3222 3223 LC->GetNeighbourBounds(Nlower, Nupper);3224 //Log() << Verbose(1) << endl;3225 for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)3226 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)3227 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {3228 const LinkedNodes *List = LC->GetCurrentCell();3229 //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;3230 if (List != NULL) {3231 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {3232 helper.CopyVector(Point);3233 helper.SubtractVector((*Runner)->node);3234 double currentNorm = helper. Norm();3235 if (PointsOnBoundary.find((*Runner)->nr) != PointsOnBoundary.end()) {3236 if (currentNorm < distance) {3237 // remember second point3238 secondDistance = distance;3239 secondClosestPoint = closestPoint;3240 // mark down new closest point3241 distance = currentNorm;3242 closestPoint = (*Runner);3243 //Log() << Verbose(2) << "INFO: New Second Nearest Neighbour is " << *secondClosestPoint << "." << endl;3244 }3245 }3246 }3247 } else {3248 eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << ","3249 << LC->n[2] << " is invalid!" << endl;3250 }3251 }3252 3253 return secondClosestPoint;3254 };3255 3256 /**3257 * Finds the point which is closest to the provided one.3258 *3259 * @param Point to which to find the closest other point3260 * @param SecondPoint the second closest other point on return, NULL if none found3261 * @param linked cell structure3262 *3263 * @return point which is closest to the provided one, NULL if none found3264 * @TODO Optimize me! These finds are unnecessary if we have a LC list of BoundaryPoints only!3265 */3266 TesselPoint* Tesselation::FindClosestBoundaryPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC) const3267 {3268 Info FunctionInfo(__func__);3269 TesselPoint* closestPoint = NULL;3270 SecondPoint = NULL;3271 double distance = 1e16;3272 double secondDistance = 1e16;3273 Vector helper;3274 int N[NDIM], Nlower[NDIM], Nupper[NDIM];3275 3276 LC->SetIndexToVector(Point); // ignore status as we calculate bounds below sensibly3277 for(int i=0;i<NDIM;i++) // store indices of this cell3278 N[i] = LC->n[i];3279 Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;3280 3281 LC->GetNeighbourBounds(Nlower, Nupper);3282 //Log() << Verbose(1) << endl;3283 for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)3284 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)3285 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {3286 const LinkedNodes *List = LC->GetCurrentCell();3287 //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;3288 if (List != NULL) {3289 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {3290 helper.CopyVector(Point);3291 helper.SubtractVector((*Runner)->node);3292 double currentNorm = helper.NormSquared();3293 if (PointsOnBoundary.find((*Runner)->nr) != PointsOnBoundary.end()) {3294 if (currentNorm < distance) {3295 secondDistance = distance;3296 SecondPoint = closestPoint;3297 distance = currentNorm;3298 closestPoint = (*Runner);3299 //Log() << Verbose(1) << "INFO: New Nearest Neighbour is " << *closestPoint << "." << endl;3300 } else if (currentNorm < secondDistance) {3301 secondDistance = currentNorm;3302 SecondPoint = (*Runner);3303 //Log() << Verbose(1) << "INFO: New Second Nearest Neighbour is " << *SecondPoint << "." << endl;3304 }3305 }3306 }3307 } else {3308 eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl;3309 }3310 }3311 // output3312 if ((closestPoint != NULL) && (SecondPoint != NULL)) {3313 Log() << Verbose(1) << "Closest point is " << *closestPoint << " and second closest is " << *SecondPoint << "." << endl;3314 } else if (closestPoint != NULL) {3315 Log() << Verbose(1) << "Closest point is " << *closestPoint << " and second closest is " << SecondPoint << "." << endl;3316 } else {3317 Log() << Verbose(1) << "No closest point has been found, only " << closestPoint << " and " << SecondPoint << "." << endl;3318 }3319 return closestPoint;3320 };3321 3322 3323 3292 /** Gets all points connected to the provided point by triangulation lines. 3324 3293 * … … 3327 3296 * @return set of the all points linked to the provided one 3328 3297 */ 3329 set<TesselPoint*>* Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const3330 { 3331 Info FunctionInfo(__func__); 3332 set<TesselPoint*> *connectedPoints = new set<TesselPoint*>;3298 TesselPointSet * Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const 3299 { 3300 Info FunctionInfo(__func__); 3301 TesselPointSet *connectedPoints = new TesselPointSet; 3333 3302 class BoundaryPointSet *ReferencePoint = NULL; 3334 3303 TesselPoint* current; … … 3392 3361 * @return list of the all points linked to the provided one 3393 3362 */ 3394 list<TesselPoint*> * Tesselation::GetCircleOfConnectedTriangles(set<TesselPoint*>*SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const3363 TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const 3395 3364 { 3396 3365 Info FunctionInfo(__func__); 3397 3366 map<double, TesselPoint*> anglesOfPoints; 3398 list<TesselPoint*> *connectedCircle = new list<TesselPoint*>;3367 TesselPointList *connectedCircle = new TesselPointList; 3399 3368 Vector PlaneNormal; 3400 3369 Vector AngleZero; … … 3402 3371 Vector helper; 3403 3372 const TesselPoint * const TrianglePoints[3] = {Point, NULL, NULL}; 3404 list<BoundaryTriangleSet*>*triangles = NULL;3373 TriangleList *triangles = NULL; 3405 3374 3406 3375 if (SetOfNeighbours == NULL) { … … 3413 3382 triangles = FindTriangles(TrianglePoints); 3414 3383 if ((triangles != NULL) && (!triangles->empty())) { 3415 for ( list<BoundaryTriangleSet*>::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++)3384 for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) 3416 3385 PlaneNormal.AddVector(&(*Runner)->NormalVector); 3417 3386 } else { … … 3447 3416 3448 3417 // go through all connected points and calculate angle 3449 for ( set<TesselPoint*>::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {3418 for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3450 3419 helper.CopyVector((*listRunner)->node); 3451 3420 helper.SubtractVector(Point->node); … … 3469 3438 * triangle we are looking for. 3470 3439 * 3471 * @param *out output stream for debugging3472 3440 * @param *SetOfNeighbours all points for which the angle should be calculated 3473 3441 * @param *Point of which get all connected points … … 3475 3443 * @return list of the all points linked to the provided one 3476 3444 */ 3477 list<TesselPoint*> * Tesselation::GetCircleOfSetOfPoints(set<TesselPoint*>*SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const3445 TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const 3478 3446 { 3479 3447 Info FunctionInfo(__func__); 3480 3448 map<double, TesselPoint*> anglesOfPoints; 3481 list<TesselPoint*> *connectedCircle = new list<TesselPoint*>;3449 TesselPointList *connectedCircle = new TesselPointList; 3482 3450 Vector center; 3483 3451 Vector PlaneNormal; … … 3493 3461 3494 3462 // calculate central point 3495 for ( set<TesselPoint*>::const_iterator TesselRunner = SetOfNeighbours->begin(); TesselRunner != SetOfNeighbours->end(); TesselRunner++)3463 for (TesselPointSet::const_iterator TesselRunner = SetOfNeighbours->begin(); TesselRunner != SetOfNeighbours->end(); TesselRunner++) 3496 3464 center.AddVector((*TesselRunner)->node); 3497 3465 //Log() << Verbose(0) << "Summed vectors " << center << "; number of points " << connectedPoints.size() … … 3530 3498 3531 3499 // go through all connected points and calculate angle 3532 for (set<TesselPoint*>::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3500 pair <map<double, TesselPoint*>::iterator, bool > InserterTest; 3501 for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3533 3502 helper.CopyVector((*listRunner)->node); 3534 3503 helper.SubtractVector(Point->node); 3535 3504 helper.ProjectOntoPlane(&PlaneNormal); 3536 3505 double angle = GetAngle(helper, AngleZero, OrthogonalVector); 3537 Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl; 3538 anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner))); 3506 Log() << Verbose(0) << "INFO: Calculated angle between " << helper << " and " << AngleZero << " is " << angle << " for point " << **listRunner << "." << endl; 3507 InserterTest = anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner))); 3508 if (!InserterTest.second) { 3509 eLog() << Verbose(0) << "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner) << endl; 3510 performCriticalExit(); 3511 } 3539 3512 } 3540 3513 … … 3552 3525 * @return list of the all points linked to the provided one 3553 3526 */ 3554 list< list<TesselPoint*>*> * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const3527 list< TesselPointList *> * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const 3555 3528 { 3556 3529 Info FunctionInfo(__func__); 3557 3530 map<double, TesselPoint*> anglesOfPoints; 3558 list< list<TesselPoint*> *> *ListOfPaths = new list<list<TesselPoint*>*>;3559 list<TesselPoint*>*connectedPath = NULL;3531 list< TesselPointList *> *ListOfPaths = new list< TesselPointList *>; 3532 TesselPointList *connectedPath = NULL; 3560 3533 Vector center; 3561 3534 Vector PlaneNormal; … … 3594 3567 } else if (!LineRunner->second) { 3595 3568 LineRunner->second = true; 3596 connectedPath = new list<TesselPoint*>;3569 connectedPath = new TesselPointList; 3597 3570 triangle = NULL; 3598 3571 CurrentLine = runner->second; … … 3668 3641 * @return list of the closed paths 3669 3642 */ 3670 list< list<TesselPoint*>*> * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const3671 { 3672 Info FunctionInfo(__func__); 3673 list< list<TesselPoint*>*> *ListofPaths = GetPathsOfConnectedPoints(Point);3674 list< list<TesselPoint*> *> *ListofClosedPaths = new list<list<TesselPoint*>*>;3675 list<TesselPoint*>*connectedPath = NULL;3676 list<TesselPoint*>*newPath = NULL;3643 list<TesselPointList *> * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const 3644 { 3645 Info FunctionInfo(__func__); 3646 list<TesselPointList *> *ListofPaths = GetPathsOfConnectedPoints(Point); 3647 list<TesselPointList *> *ListofClosedPaths = new list<TesselPointList *>; 3648 TesselPointList *connectedPath = NULL; 3649 TesselPointList *newPath = NULL; 3677 3650 int count = 0; 3678 3651 3679 3652 3680 list<TesselPoint*>::iterator CircleRunner;3681 list<TesselPoint*>::iterator CircleStart;3682 3683 for(list< list<TesselPoint*>*>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) {3653 TesselPointList::iterator CircleRunner; 3654 TesselPointList::iterator CircleStart; 3655 3656 for(list<TesselPointList *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) { 3684 3657 connectedPath = *ListRunner; 3685 3658 … … 3690 3663 3691 3664 // go through list, look for reappearance of starting Point and create list 3692 list<TesselPoint*>::iterator Marker = CircleStart;3665 TesselPointList::iterator Marker = CircleStart; 3693 3666 for (CircleRunner = CircleStart; CircleRunner != connectedPath->end(); CircleRunner++) { 3694 3667 if ((*CircleRunner == *CircleStart) && (CircleRunner != CircleStart)) { // is not the very first point 3695 3668 // we have a closed circle from Marker to new Marker 3696 3669 Log() << Verbose(1) << count+1 << ". closed path consists of: "; 3697 newPath = new list<TesselPoint*>;3698 list<TesselPoint*>::iterator CircleSprinter = Marker;3670 newPath = new TesselPointList; 3671 TesselPointList::iterator CircleSprinter = Marker; 3699 3672 for (; CircleSprinter != CircleRunner; CircleSprinter++) { 3700 3673 newPath->push_back(*CircleSprinter); … … 3730 3703 * \return pointer to allocated list of triangles 3731 3704 */ 3732 set<BoundaryTriangleSet*>*Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const3733 { 3734 Info FunctionInfo(__func__); 3735 set<BoundaryTriangleSet*> *connectedTriangles = new set<BoundaryTriangleSet*>;3705 TriangleSet *Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const 3706 { 3707 Info FunctionInfo(__func__); 3708 TriangleSet *connectedTriangles = new TriangleSet; 3736 3709 3737 3710 if (Point == NULL) { … … 3782 3755 } 3783 3756 3784 list< list<TesselPoint*>*> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(point->node);3785 list<TesselPoint*>*connectedPath = NULL;3757 list<TesselPointList *> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(point->node); 3758 TesselPointList *connectedPath = NULL; 3786 3759 3787 3760 // gather all triangles 3788 3761 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) 3789 3762 count+=LineRunner->second->triangles.size(); 3790 map<class BoundaryTriangleSet *, int>Candidates;3763 TriangleMap Candidates; 3791 3764 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 3792 3765 line = LineRunner->second; 3793 3766 for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) { 3794 3767 triangle = TriangleRunner->second; 3795 Candidates.insert( pair<class BoundaryTriangleSet *, int> (triangle, triangle->Nr) );3768 Candidates.insert( TrianglePair (triangle->Nr, triangle) ); 3796 3769 } 3797 3770 } … … 3800 3773 count=0; 3801 3774 NormalVector.Zero(); 3802 for ( map<class BoundaryTriangleSet *, int>::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) {3803 Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner-> first) << "." << endl;3804 NormalVector.SubtractVector(&Runner-> first->NormalVector); // has to point inward3805 RemoveTesselationTriangle(Runner-> first);3775 for (TriangleMap::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) { 3776 Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl; 3777 NormalVector.SubtractVector(&Runner->second->NormalVector); // has to point inward 3778 RemoveTesselationTriangle(Runner->second); 3806 3779 count++; 3807 3780 } 3808 3781 Log() << Verbose(1) << count << " triangles were removed." << endl; 3809 3782 3810 list< list<TesselPoint*>*>::iterator ListAdvance = ListOfClosedPaths->begin();3811 list< list<TesselPoint*>*>::iterator ListRunner = ListAdvance;3812 map<class BoundaryTriangleSet *, int>::iterator NumberRunner = Candidates.begin();3813 list<TesselPoint*>::iterator StartNode, MiddleNode, EndNode;3783 list<TesselPointList *>::iterator ListAdvance = ListOfClosedPaths->begin(); 3784 list<TesselPointList *>::iterator ListRunner = ListAdvance; 3785 TriangleMap::iterator NumberRunner = Candidates.begin(); 3786 TesselPointList::iterator StartNode, MiddleNode, EndNode; 3814 3787 double angle; 3815 3788 double smallestangle; … … 3825 3798 3826 3799 // re-create all triangles by going through connected points list 3827 list<class BoundaryLineSet *>NewLines;3800 LineList NewLines; 3828 3801 for (;!connectedPath->empty();) { 3829 3802 // search middle node with widest angle to next neighbours … … 3931 3904 // maximize the inner lines (we preferentially created lines with a huge angle, which is for the tesselation not wanted though useful for the closing) 3932 3905 if (NewLines.size() > 1) { 3933 list<class BoundaryLineSet *>::iterator Candidate;3906 LineList::iterator Candidate; 3934 3907 class BoundaryLineSet *OtherBase = NULL; 3935 3908 double tmp, maxgain; 3936 3909 do { 3937 3910 maxgain = 0; 3938 for( list<class BoundaryLineSet *>::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {3911 for(LineList::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) { 3939 3912 tmp = PickFarthestofTwoBaselines(*Runner); 3940 3913 if (maxgain < tmp) { … … 3983 3956 * will usually be one, in case of degeneration, there will be two 3984 3957 */ 3985 list<BoundaryTriangleSet*>*Tesselation::FindTriangles(const TesselPoint* const Points[3]) const3986 { 3987 Info FunctionInfo(__func__); 3988 list<BoundaryTriangleSet*> *result = new list<BoundaryTriangleSet*>;3958 TriangleList *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const 3959 { 3960 Info FunctionInfo(__func__); 3961 TriangleList *result = new TriangleList; 3989 3962 LineMap::const_iterator FindLine; 3990 3963 TriangleMap::const_iterator FindTriangle; … … 4114 4087 * in the list, once as key and once as value 4115 4088 */ 4116 map<int, int>* Tesselation::FindAllDegeneratedLines()4089 IndexToIndex * Tesselation::FindAllDegeneratedLines() 4117 4090 { 4118 4091 Info FunctionInfo(__func__); 4119 4092 UniqueLines AllLines; 4120 map<int, int> * DegeneratedLines = new map<int, int>;4093 IndexToIndex * DegeneratedLines = new IndexToIndex; 4121 4094 4122 4095 // sanity check … … 4139 4112 4140 4113 Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl; 4141 map<int,int>::iterator it;4114 IndexToIndex::iterator it; 4142 4115 for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) { 4143 4116 const LineMap::const_iterator Line1 = LinesOnBoundary.find((*it).first); … … 4158 4131 * in the list, once as key and once as value 4159 4132 */ 4160 map<int, int>* Tesselation::FindAllDegeneratedTriangles()4161 { 4162 Info FunctionInfo(__func__); 4163 map<int, int>* DegeneratedLines = FindAllDegeneratedLines();4164 map<int, int> * DegeneratedTriangles = new map<int, int>;4133 IndexToIndex * Tesselation::FindAllDegeneratedTriangles() 4134 { 4135 Info FunctionInfo(__func__); 4136 IndexToIndex * DegeneratedLines = FindAllDegeneratedLines(); 4137 IndexToIndex * DegeneratedTriangles = new IndexToIndex; 4165 4138 4166 4139 TriangleMap::iterator TriangleRunner1, TriangleRunner2; … … 4168 4141 class BoundaryLineSet *line1 = NULL, *line2 = NULL; 4169 4142 4170 for ( map<int, int>::iterator LineRunner = DegeneratedLines->begin(); LineRunner != DegeneratedLines->end(); ++LineRunner) {4143 for (IndexToIndex::iterator LineRunner = DegeneratedLines->begin(); LineRunner != DegeneratedLines->end(); ++LineRunner) { 4171 4144 // run over both lines' triangles 4172 4145 Liner = LinesOnBoundary.find(LineRunner->first); … … 4189 4162 4190 4163 Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl; 4191 map<int,int>::iterator it;4164 IndexToIndex::iterator it; 4192 4165 for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 4193 4166 Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl; … … 4203 4176 { 4204 4177 Info FunctionInfo(__func__); 4205 map<int, int>* DegeneratedTriangles = FindAllDegeneratedTriangles();4178 IndexToIndex * DegeneratedTriangles = FindAllDegeneratedTriangles(); 4206 4179 TriangleMap::iterator finder; 4207 4180 BoundaryTriangleSet *triangle = NULL, *partnerTriangle = NULL; 4208 4181 int count = 0; 4209 4182 4210 for ( map<int, int>::iterator TriangleKeyRunner = DegeneratedTriangles->begin();4183 for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); 4211 4184 TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner 4212 4185 ) { … … 4463 4436 4464 4437 /// 2. Go through all BoundaryPointSet's, check their triangles' NormalVector 4465 map <int, int>*DegeneratedTriangles = FindAllDegeneratedTriangles();4438 IndexToIndex *DegeneratedTriangles = FindAllDegeneratedTriangles(); 4466 4439 set < BoundaryPointSet *> EndpointCandidateList; 4467 4440 pair < set < BoundaryPointSet *>::iterator, bool > InsertionTester; … … 4615 4588 } 4616 4589 4617 map<int, int>* SimplyDegeneratedTriangles = FindAllDegeneratedTriangles();4590 IndexToIndex * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles(); 4618 4591 Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl; 4619 map<int,int>::iterator it;4592 IndexToIndex::iterator it; 4620 4593 for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++) 4621 4594 Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl; -
src/tesselation.hpp
r71b20e rc15ca2 52 52 // ======================================================= some template functions ========================================= 53 53 54 #define IndexToIndex map <int, int> 55 54 56 #define PointMap map < int, class BoundaryPointSet * > 55 57 #define PointSet set < class BoundaryPointSet * > … … 76 78 #define PolygonSet set < class BoundaryPolygonSet * > 77 79 #define PolygonList list < class BoundaryPolygonSet * > 80 81 #define DistanceMap multimap <double, class BoundaryPointSet * > 82 #define DistancePair pair <double, class BoundaryPointSet * > 78 83 79 84 #define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> > … … 310 315 bool IsInnerPoint(const TesselPoint * const Point, const LinkedCell* const LC, const double epsilon = -MYEPSILON) const; 311 316 bool AddBoundaryPoint(TesselPoint * Walker, const int n); 312 TesselPoint* FindSecondClosestBoundaryPoint(const Vector* Point, const LinkedCell* const LC) const; 313 TesselPoint* FindClosestBoundaryPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC) const; 317 DistanceMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const; 318 BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const; 319 TriangleList * FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const; 320 BoundaryTriangleSet* FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const; 314 321 315 322 // print for debugging -
src/unittests/Makefile.am
r71b20e rc15ca2 4 4 AM_CXXFLAGS = $(CPPUNIT_CFLAGS) 5 5 6 TESTS = ActOnAllUnitTest AnalysisBondsUnitTests AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest BondGraphUnitTest InfoUnitTest ListOfBondsUnitTest LogUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest StackClassUnitTest VectorUnitTest6 TESTS = ActOnAllUnitTest AnalysisBondsUnitTests AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest BondGraphUnitTest InfoUnitTest ListOfBondsUnitTest LogUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest StackClassUnitTest TesselationUnitTest TesselationInOutsideUnitTest VectorUnitTest 7 7 check_PROGRAMS = $(TESTS) 8 8 noinst_PROGRAMS = $(TESTS) … … 44 44 StackClassUnitTest_LDADD = ../libmolecuilder.a 45 45 46 TesselationUnitTest_SOURCES = tesselationunittest.cpp tesselationunittest.hpp 47 TesselationUnitTest_LDADD = ../libmolecuilder.a 48 49 TesselationInOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp 50 TesselationInOutsideUnitTest_LDADD = ../libmolecuilder.a 51 46 52 VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp 47 53 VectorUnitTest_LDADD = ../libmolecuilder.a -
src/unittests/tesselationunittest.cpp
r71b20e rc15ca2 30 30 class TesselPoint *Walker; 31 31 Walker = new TesselPoint; 32 Walker->node = new Vector(1., 0., 0.);33 Walker->Name = new char[3];32 Walker->node = new Vector(1., 0., -1.); 33 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 34 34 strcpy(Walker->Name, "1"); 35 35 Walker->nr = 1; 36 36 Corners.push_back(Walker); 37 37 Walker = new TesselPoint; 38 Walker->node = new Vector(-1., 1., 0.);39 Walker->Name = new char[3];38 Walker->node = new Vector(-1., 1., -1.); 39 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 40 40 strcpy(Walker->Name, "2"); 41 41 Walker->nr = 2; 42 42 Corners.push_back(Walker); 43 43 Walker = new TesselPoint; 44 Walker->node = new Vector(-1., -1., 0.);45 Walker->Name = new char[3];44 Walker->node = new Vector(-1., -1., -1.); 45 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 46 46 strcpy(Walker->Name, "3"); 47 47 Walker->nr = 3; … … 49 49 Walker = new TesselPoint; 50 50 Walker->node = new Vector(-1., 0., 1.); 51 Walker->Name = new char[3];51 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 52 52 strcpy(Walker->Name, "4"); 53 53 Walker->nr = 4; … … 59 59 // create tesselation 60 60 TesselStruct = new Tesselation; 61 TesselStruct->PointsOnBoundary.clear();62 TesselStruct->LinesOnBoundary.clear();63 TesselStruct->TrianglesOnBoundary.clear();61 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->PointsOnBoundary.empty() ); 62 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->LinesOnBoundary.empty() ); 63 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->TrianglesOnBoundary.empty() ); 64 64 TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList); 65 bool flag = false;66 65 67 LineMap::iterator baseline = TesselStruct->LinesOnBoundary.begin(); 68 while (baseline != TesselStruct->LinesOnBoundary.end()) { 69 if (baseline->second->triangles.size() == 1) { 70 flag = TesselStruct->FindNextSuitableTriangle(*(baseline->second), *(((baseline->second->triangles.begin()))->second), SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one. 66 CandidateForTesselation *baseline = NULL; 67 BoundaryTriangleSet *T = NULL; 68 bool OneLoopWithoutSuccessFlag = true; 69 bool TesselationFailFlag = false; 70 while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) { 71 // 2a. fill all new OpenLines 72 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) { 73 baseline = Runner->second; 74 if (baseline->pointlist.empty()) { 75 T = (((baseline->BaseLine->triangles.begin()))->second); 76 TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one. 77 } 71 78 } 72 baseline++; 73 if ((baseline == TesselStruct->LinesOnBoundary.end()) && (flag)) { 74 baseline = TesselStruct->LinesOnBoundary.begin(); // restart if we reach end due to newly inserted lines 75 flag = false; 79 80 // 2b. search for smallest ShortestAngle among all candidates 81 double ShortestAngle = 4.*M_PI; 82 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) { 83 if (Runner->second->ShortestAngle < ShortestAngle) { 84 baseline = Runner->second; 85 ShortestAngle = baseline->ShortestAngle; 86 } 87 } 88 if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty())) 89 OneLoopWithoutSuccessFlag = false; 90 else { 91 TesselStruct->AddCandidateTriangle(*baseline); 76 92 } 77 93 } … … 84 100 delete(TesselStruct); 85 101 for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 86 delete[]((*Runner)->Name);87 102 delete((*Runner)->node); 88 103 delete(*Runner); 89 104 } 90 105 Corners.clear(); 91 }; 92 93 /** UnitTest for Tesselation::IsInnerPoint() 94 */ 95 void TesselationTest::IsInnerPointTest() 96 { 97 // true inside points 98 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.), LinkedList) ); 99 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.5,0.,0.), LinkedList) ); 100 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.5,0.), LinkedList) ); 101 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.5), LinkedList) ); 102 103 // corners 104 for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) 105 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint((*Runner), LinkedList) ); 106 107 // true outside points 108 CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,5.,0.), LinkedList) ); 109 CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,0.,5.), LinkedList) ); 110 CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(1.,1.,1.), LinkedList) ); 111 112 // tricky point, there are three equally close triangles 113 CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(5.,0.,0.), LinkedList) ); 114 106 MemoryUsageObserver::purgeInstance(); 107 logger::purgeInstance(); 108 errorLogger::purgeInstance(); 115 109 }; 116 110 -
src/unittests/tesselationunittest.hpp
r71b20e rc15ca2 21 21 { 22 22 CPPUNIT_TEST_SUITE( TesselationTest) ; 23 CPPUNIT_TEST ( IsInnerPointTest );24 23 CPPUNIT_TEST ( GetAllTrianglesTest ); 25 24 CPPUNIT_TEST ( ContainmentTest ); … … 29 28 void setUp(); 30 29 void tearDown(); 31 void IsInnerPointTest();32 30 void GetAllTrianglesTest(); 33 31 void ContainmentTest();
Note:
See TracChangeset
for help on using the changeset viewer.