- Timestamp:
- Dec 16, 2009, 11:53:06 AM (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:
- 009e37b
- Parents:
- 5e8f82
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/bondgraph.cpp
r5e8f82 rb998c3 35 35 /** Parses the bond lengths in a given file and puts them int a matrix form. 36 36 * Allocates \a MatrixContainer for BondGraph::BondLengthMatrix, using MatrixContainer::ParseMatrix(), 37 * but only if parsing is successful l. Otherwise variable is left as NULL.37 * but only if parsing is successful. Otherwise variable is left as NULL. 38 38 * \param *out output stream for debugging 39 39 * \param filename file with bond lengths to parse -
src/boundary.cpp
r5e8f82 rb998c3 1041 1041 // TesselStruct->RemoveDegeneratedTriangles(); 1042 1042 1043 // check envelope for consistency 1044 status = CheckListOfBaselines(TesselStruct); 1045 1046 // store before correction 1047 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, ""); 1048 1043 1049 // correct degenerated polygons 1044 1050 TesselStruct->CorrectAllDegeneratedPolygons(); -
src/boundary.hpp
r5e8f82 rb998c3 36 36 #define DEBUG 1 37 37 #define DoSingleStepOutput 0 38 #define SingleStepWidth 1 38 #define SingleStepWidth 10 39 39 40 40 #define DistancePair pair < double, atom* > -
src/tesselation.cpp
r5e8f82 rb998c3 879 879 CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) : 880 880 BaseLine(line), 881 IsDegenerated(false), 881 882 ShortestAngle(2.*M_PI), 882 883 OtherShortestAngle(2.*M_PI) … … 1587 1588 bool insertNewLine = true; 1588 1589 1589 if (a->lines.find(b->node->nr) != a->lines.end()) { 1590 LineMap::iterator FindLine = a->lines.find(b->node->nr); 1590 LineMap::iterator FindLine = a->lines.find(b->node->nr); 1591 if (FindLine != a->lines.end()) { 1592 Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl; 1593 1591 1594 pair<LineMap::iterator,LineMap::iterator> FindPair; 1592 1595 FindPair = a->lines.equal_range(b->node->nr); 1593 Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl;1594 1596 1595 1597 for (FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) { … … 1915 1917 double maxCoordinate[NDIM]; 1916 1918 BoundaryLineSet BaseLine; 1917 Vector Oben;1918 1919 Vector helper; 1919 1920 Vector Chord; 1920 1921 Vector SearchDirection; 1921 1922 Oben.Zero(); 1922 Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers 1923 Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in 1924 Vector SphereCenter; 1925 Vector NormalVector; 1926 1927 NormalVector.Zero(); 1923 1928 1924 1929 for (i = 0; i < 3; i++) { … … 1955 1960 BTS = NULL; 1956 1961 for (int k=0;k<NDIM;k++) { 1957 Oben.Zero();1958 Oben.x[k] = 1.;1962 NormalVector.Zero(); 1963 NormalVector.x[k] = 1.; 1959 1964 BaseLine.endpoints[0] = new BoundaryPointSet(MaxPoint[k]); 1960 1965 Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl; … … 1963 1968 ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant. 1964 1969 1965 FindSecondPointForTesselation(BaseLine.endpoints[0]->node, Oben, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...1970 FindSecondPointForTesselation(BaseLine.endpoints[0]->node, NormalVector, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_... 1966 1971 if (Temporary == NULL) // have we found a second point? 1967 1972 continue; 1968 1973 BaseLine.endpoints[1] = new BoundaryPointSet(Temporary); 1969 1974 1970 helper.CopyVector(BaseLine.endpoints[0]->node->node); 1971 helper.SubtractVector(BaseLine.endpoints[1]->node->node); 1972 helper.Normalize(); 1973 Oben.ProjectOntoPlane(&helper); 1974 Oben.Normalize(); 1975 helper.VectorProduct(&Oben); 1975 // construct center of circle 1976 CircleCenter.CopyVector(BaseLine.endpoints[0]->node->node); 1977 CircleCenter.AddVector(BaseLine.endpoints[1]->node->node); 1978 CircleCenter.Scale(0.5); 1979 1980 // construct normal vector of circle 1981 CirclePlaneNormal.CopyVector(BaseLine.endpoints[0]->node->node); 1982 CirclePlaneNormal.SubtractVector(BaseLine.endpoints[1]->node->node); 1983 1984 double radius = CirclePlaneNormal.NormSquared(); 1985 double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.); 1986 1987 NormalVector.ProjectOntoPlane(&CirclePlaneNormal); 1988 NormalVector.Normalize(); 1976 1989 ShortestAngle = 2.*M_PI; // This will indicate the quadrant. 1977 1990 1978 Chord.CopyVector(BaseLine.endpoints[0]->node->node); // bring into calling function 1979 Chord.SubtractVector(BaseLine.endpoints[1]->node->node); 1980 double radius = Chord.ScalarProduct(&Chord); 1981 double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.); 1982 helper.CopyVector(&Oben); 1983 helper.Scale(CircleRadius); 1984 // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized) 1991 SphereCenter.CopyVector(&NormalVector); 1992 SphereCenter.Scale(CircleRadius); 1993 SphereCenter.AddVector(&CircleCenter); 1994 // Now, NormalVector and SphereCenter are two orthonormalized vectors in the plane defined by CirclePlaneNormal (not normalized) 1985 1995 1986 1996 // look in one direction of baseline for initial candidate 1987 SearchDirection.MakeNormalVector(&C hord, &Oben); // whether we look "left" first or "right" first is not important ...1997 SearchDirection.MakeNormalVector(&CirclePlaneNormal, &NormalVector); // whether we look "left" first or "right" first is not important ... 1988 1998 1989 1999 // adding point 1 and point 2 and add the line between them … … 1993 2003 //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << helper << ".\n"; 1994 2004 CandidateForTesselation OptCandidates(&BaseLine); 1995 FindThirdPointForTesselation( Oben, SearchDirection, helper, OptCandidates, NULL, RADIUS, LC);2005 FindThirdPointForTesselation(NormalVector, SearchDirection, SphereCenter, OptCandidates, NULL, RADIUS, LC); 1996 2006 Log() << Verbose(0) << "List of third Points is:" << endl; 1997 2007 for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); it++) { … … 2167 2177 Vector CircleCenter; 2168 2178 Vector CirclePlaneNormal; 2169 Vector OldSphereCenter;2179 Vector RelativeSphereCenter; 2170 2180 Vector SearchDirection; 2171 2181 Vector helper; … … 2174 2184 double radius, CircleRadius; 2175 2185 2176 Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " of triangle " << T << "." << endl;2177 2186 for (int i=0;i<3;i++) 2178 if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node)) 2187 if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node)) { 2179 2188 ThirdNode = T.endpoints[i]->node; 2189 break; 2190 } 2191 Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdNode " << *ThirdNode << " of triangle " << T << "." << endl; 2180 2192 2181 2193 // construct center of circle … … 2191 2203 radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal); 2192 2204 if (radius/4. < RADIUS*RADIUS) { 2205 // construct relative sphere center with now known CircleCenter 2206 RelativeSphereCenter.CopyVector(&T.SphereCenter); 2207 RelativeSphereCenter.SubtractVector(&CircleCenter); 2208 2193 2209 CircleRadius = RADIUS*RADIUS - radius/4.; 2194 2210 CirclePlaneNormal.Normalize(); 2195 2211 Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 2196 2212 2197 // construct old center 2198 GetCenterofCircumcircle(&OldSphereCenter, *T.endpoints[0]->node->node, *T.endpoints[1]->node->node, *T.endpoints[2]->node->node); 2199 helper.CopyVector(&T.NormalVector); // normal vector ensures that this is correct center of the two possible ones 2200 radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&OldSphereCenter); 2201 helper.Scale(sqrt(RADIUS*RADIUS - radius)); 2202 OldSphereCenter.AddVector(&helper); 2203 OldSphereCenter.SubtractVector(&CircleCenter); 2204 Log() << Verbose(1) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl; 2205 2206 // construct SearchDirection 2207 SearchDirection.MakeNormalVector(&T.NormalVector, &CirclePlaneNormal); 2208 helper.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node); 2213 Log() << Verbose(1) << "INFO: OldSphereCenter is at " << T.SphereCenter << "." << endl; 2214 2215 // construct SearchDirection and an "outward pointer" 2216 SearchDirection.MakeNormalVector(&RelativeSphereCenter, &CirclePlaneNormal); 2217 helper.CopyVector(&CircleCenter); 2209 2218 helper.SubtractVector(ThirdNode->node); 2210 2219 if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards! 2211 2220 SearchDirection.Scale(-1.); 2212 SearchDirection.ProjectOntoPlane(&OldSphereCenter);2213 SearchDirection.Normalize();2214 2221 Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 2215 if (fabs( OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {2222 if (fabs(RelativeSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { 2216 2223 // rotated the wrong way! 2217 2224 eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl; … … 2219 2226 2220 2227 // add third point 2221 FindThirdPointForTesselation(T.NormalVector, SearchDirection, OldSphereCenter, CandidateLine, ThirdNode, RADIUS, LC);2228 FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdNode, RADIUS, LC); 2222 2229 2223 2230 } else { … … 2350 2357 AddTesselationPoint((*Sprinter), 2); 2351 2358 2352 Center.CopyVector(&CandidateLine.OptCenter); 2359 2353 2360 // add the lines 2354 2361 AddTesselationLine(TPS[0], TPS[1], 0); … … 2359 2366 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2360 2367 AddTesselationTriangle(); 2361 Center.Scale(-1.); 2368 BTS->GetCenter(&Center); 2369 Center.SubtractVector(&CandidateLine.OptCenter); 2370 BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter); 2362 2371 BTS->GetNormalVector(Center); 2363 2372 … … 2766 2775 Vector NewNormalVector; // normal vector of the Candidate's triangle 2767 2776 Vector helper, OptCandidateCenter, OtherOptCandidateCenter; 2777 Vector RelativeOldSphereCenter; 2778 Vector NewPlaneCenter; 2768 2779 double CircleRadius; // radius of this circle 2769 2780 double radius; 2781 double otherradius; 2770 2782 double alpha, Otheralpha; // angles (i.e. parameter for the circle). 2783 bool IsDegenerated; 2771 2784 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; 2772 2785 TesselPoint *Candidate = NULL; 2786 TesselPoint *CandidateTriangle[3]; 2773 2787 2774 2788 Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl; … … 2783 2797 CirclePlaneNormal.SubtractVector(CandidateLine.BaseLine->endpoints[1]->node->node); 2784 2798 2799 RelativeOldSphereCenter.CopyVector(&OldSphereCenter); 2800 RelativeOldSphereCenter.SubtractVector(&CircleCenter); 2801 2802 CandidateTriangle[0] = CandidateLine.BaseLine->endpoints[0]->node; 2803 CandidateTriangle[1] = CandidateLine.BaseLine->endpoints[1]->node; 2804 2785 2805 // calculate squared radius TesselPoint *ThirdNode,f circle 2786 radius = CirclePlaneNormal. ScalarProduct(&CirclePlaneNormal);2787 if (radius /4.< RADIUS*RADIUS) {2788 CircleRadius = RADIUS*RADIUS - radius /4.;2806 radius = CirclePlaneNormal.NormSquared()/4.; 2807 if (radius < RADIUS*RADIUS) { 2808 CircleRadius = RADIUS*RADIUS - radius; 2789 2809 CirclePlaneNormal.Normalize(); 2790 //Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;2810 Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 2791 2811 2792 2812 // test whether old center is on the band's plane 2793 if (fabs( OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {2794 eLog() << Verbose(1) << "Something's very wrong here: OldSphereCenter is not on the band's plane as desired by " << fabs(OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;2795 OldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal);2796 } 2797 radius = OldSphereCenter.ScalarProduct(&OldSphereCenter);2813 if (fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) { 2814 eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl; 2815 RelativeOldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal); 2816 } 2817 radius = RelativeOldSphereCenter.NormSquared(); 2798 2818 if (fabs(radius - CircleRadius) < HULLEPSILON) { 2799 //Log() << Verbose(1) << "INFO: OldSphereCenter is at " <<OldSphereCenter << "." << endl;2819 Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl; 2800 2820 2801 2821 // check SearchDirection 2802 //Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;2803 if (fabs( OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { // rotated the wrong way!2822 Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 2823 if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { // rotated the wrong way! 2804 2824 eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl; 2805 2825 } … … 2832 2852 2833 2853 // check for three unique points 2834 Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " at " << *(Candidate->node)<< "." << endl;2854 Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " for BaseLine " << *CandidateLine.BaseLine << " with OldSphereCenter " << OldSphereCenter << "." << endl; 2835 2855 if ((Candidate != CandidateLine.BaseLine->endpoints[0]->node) && (Candidate != CandidateLine.BaseLine->endpoints[1]->node) ){ 2836 2856 2837 // construct both new centers2838 GetCenterofCircumcircle(&New SphereCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node);2839 OtherNewSphereCenter.CopyVector(&NewSphereCenter);2857 // find center on the plane 2858 GetCenterofCircumcircle(&NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node); 2859 Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl; 2840 2860 2841 2861 if ((NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node)) 2842 && (fabs(NewNormalVector. ScalarProduct(&NewNormalVector)) > HULLEPSILON)2862 && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON) 2843 2863 ) { 2844 helper.CopyVector(&NewNormalVector);2845 2864 Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl; 2846 radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewSphereCenter); 2865 radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewPlaneCenter); 2866 Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 2867 Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 2868 Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl; 2847 2869 if (radius < RADIUS*RADIUS) { 2870 otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(&NewPlaneCenter); 2871 if (fabs(radius - otherradius) > HULLEPSILON) { 2872 eLog() << Verbose(1) << "Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius-otherradius) << endl; 2873 } 2874 // construct both new centers 2875 NewSphereCenter.CopyVector(&NewPlaneCenter); 2876 OtherNewSphereCenter.CopyVector(&NewPlaneCenter); 2877 helper.CopyVector(&NewNormalVector); 2848 2878 helper.Scale(sqrt(RADIUS*RADIUS - radius)); 2849 Log() << Verbose(2) << "INFO: Distance of New CircleCenter to NewSphereCenter is " << helper.Norm()<< " with sphere radius " << RADIUS << "." << endl;2879 Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl; 2850 2880 NewSphereCenter.AddVector(&helper); 2851 NewSphereCenter.SubtractVector(&CircleCenter);2852 2881 Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl; 2853 2854 2882 // OtherNewSphereCenter is created by the same vector just in the other direction 2855 2883 helper.Scale(-1.); 2856 2884 OtherNewSphereCenter.AddVector(&helper); 2857 OtherNewSphereCenter.SubtractVector(&CircleCenter);2858 2885 Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl; 2859 2886 … … 2861 2888 Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection); 2862 2889 alpha = min(alpha, Otheralpha); 2863 // if there is a better candidate, drop the current list and add the new candidate 2864 // otherwise ignore the new candidate and keep the list 2865 if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) { 2866 if (fabs(alpha - Otheralpha) > MYEPSILON) { 2867 CandidateLine.OptCenter.CopyVector(&NewSphereCenter); 2868 CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter); 2890 2891 CandidateTriangle[2] = Candidate; 2892 // the idea of the IsDegenerated flag is not to put a penalty on degenerated triangles, but to push them to the 2893 // very end of the Tesselation::OpenLines list. 2894 IsDegenerated = (CheckPresenceOfTriangle(CandidateTriangle) >= 3); 2895 if (!IsDegenerated && CandidateLine.IsDegenerated) { // if current is not, but old one was, comparison would be unfair 2896 // if there is a better candidate, drop the current list and add the new candidate 2897 // otherwise ignore the new candidate and keep the list 2898 if (CandidateLine.ShortestAngle-2.*M_PI > (alpha - HULLEPSILON)) { 2899 if (fabs(alpha - Otheralpha) > MYEPSILON) { 2900 CandidateLine.OptCenter.CopyVector(&NewSphereCenter); 2901 CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter); 2902 } else { 2903 CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter); 2904 CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter); 2905 } 2906 // if there is an equal candidate, add it to the list without clearing the list 2907 if ((CandidateLine.ShortestAngle-2.*M_PI - HULLEPSILON) < alpha) { 2908 CandidateLine.pointlist.push_back(Candidate); 2909 Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " 2910 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2911 } else { 2912 // remove all candidates from the list and then the list itself 2913 CandidateLine.pointlist.clear(); 2914 CandidateLine.pointlist.push_back(Candidate); 2915 Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " 2916 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2917 } 2918 CandidateLine.ShortestAngle = alpha; 2919 CandidateLine.IsDegenerated = IsDegenerated; 2920 if (IsDegenerated) 2921 CandidateLine.ShortestAngle += 2.*M_PI; 2922 Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl; 2869 2923 } else { 2870 CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter); 2871 CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter); 2924 if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) { 2925 Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl; 2926 } else { 2927 Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl; 2928 } 2872 2929 } 2873 // if there is an equal candidate, add it to the list without clearing the list 2874 if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) { 2875 CandidateLine.pointlist.push_back(Candidate); 2876 Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " 2877 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2930 } else { 2931 // if there is a better candidate, drop the current list and add the new candidate 2932 // otherwise ignore the new candidate and keep the list 2933 if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) { 2934 if (fabs(alpha - Otheralpha) > MYEPSILON) { 2935 CandidateLine.OptCenter.CopyVector(&NewSphereCenter); 2936 CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter); 2937 } else { 2938 CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter); 2939 CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter); 2940 } 2941 // if there is an equal candidate, add it to the list without clearing the list 2942 if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) { 2943 CandidateLine.pointlist.push_back(Candidate); 2944 Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " 2945 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2946 } else { 2947 // remove all candidates from the list and then the list itself 2948 CandidateLine.pointlist.clear(); 2949 CandidateLine.pointlist.push_back(Candidate); 2950 Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " 2951 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2952 } 2953 CandidateLine.ShortestAngle = alpha; 2954 Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl; 2878 2955 } else { 2879 // remove all candidates from the list and then the list itself 2880 CandidateLine.pointlist.clear(); 2881 CandidateLine.pointlist.push_back(Candidate); 2882 Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " 2883 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2884 } 2885 CandidateLine.ShortestAngle = alpha; 2886 Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl; 2887 } else { 2888 if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) { 2889 Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl; 2890 } else { 2891 Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl; 2956 if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) { 2957 Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl; 2958 } else { 2959 Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl; 2960 } 2892 2961 } 2893 2962 } … … 4128 4197 4129 4198 /// 2. Go through all BoundaryPointSet's, check their triangles' NormalVector 4199 map <int, int> *DegeneratedTriangles = FindAllDegeneratedTriangles(); 4130 4200 set < BoundaryPointSet *> EndpointCandidateList; 4131 4201 pair < set < BoundaryPointSet *>::iterator, bool > InsertionTester; … … 4138 4208 for (LineMap::const_iterator LineRunner = (Runner->second)->lines.begin(); LineRunner != (Runner->second)->lines.end(); LineRunner++) 4139 4209 for (TriangleMap::const_iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) { 4140 TriangleInsertionTester = TriangleVectors.insert( pair< int, Vector *> ((TriangleRunner->second)->Nr, &((TriangleRunner->second)->NormalVector)) ); 4141 if (TriangleInsertionTester.second) 4142 Log() << Verbose(1) << " Adding triangle " << *(TriangleRunner->second) << " to triangles to check-list." << endl; 4210 if (DegeneratedTriangles->find(TriangleRunner->second->Nr) == DegeneratedTriangles->end()) { 4211 TriangleInsertionTester = TriangleVectors.insert( pair< int, Vector *> ((TriangleRunner->second)->Nr, &((TriangleRunner->second)->NormalVector)) ); 4212 if (TriangleInsertionTester.second) 4213 Log() << Verbose(1) << " Adding triangle " << *(TriangleRunner->second) << " to triangles to check-list." << endl; 4214 } else { 4215 Log() << Verbose(1) << " NOT adding triangle " << *(TriangleRunner->second) << " as it's a simply degenerated one." << endl; 4216 } 4143 4217 } 4144 4218 // check whether there are two that are parallel … … 4213 4287 /// 4a. Gather all triangles of this polygon 4214 4288 TriangleSet *T = (*PolygonRunner)->GetAllContainedTrianglesFromEndpoints(); 4289 4290 if (T->size() == 2) { 4291 Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl; 4292 delete(T); 4293 continue; 4294 } 4215 4295 4216 4296 TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator -
src/tesselation.hpp
r5e8f82 rb998c3 158 158 class BoundaryLineSet *lines[3]; 159 159 Vector NormalVector; 160 Vector SphereCenter; 160 161 int Nr; 161 162 }; … … 245 246 Vector OptCenter; 246 247 Vector OtherOptCenter; 248 bool IsDegenerated; 247 249 double ShortestAngle; 248 250 double OtherShortestAngle; -
src/tesselationhelpers.cpp
r5e8f82 rb998c3 226 226 Vector helper; 227 227 double radius, alpha; 228 229 helper.CopyVector(&NewSphereCenter); 228 Vector RelativeOldSphereCenter; 229 Vector RelativeNewSphereCenter; 230 231 RelativeOldSphereCenter.CopyVector(&OldSphereCenter); 232 RelativeOldSphereCenter.SubtractVector(&CircleCenter); 233 RelativeNewSphereCenter.CopyVector(&NewSphereCenter); 234 RelativeNewSphereCenter.SubtractVector(&CircleCenter); 235 helper.CopyVector(&RelativeNewSphereCenter); 230 236 // test whether new center is on the parameter circle's plane 231 237 if (fabs(helper.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) { … … 233 239 helper.ProjectOntoPlane(&CirclePlaneNormal); 234 240 } 235 radius = helper. ScalarProduct(&helper);241 radius = helper.NormSquared(); 236 242 // test whether the new center vector has length of CircleRadius 237 243 if (fabs(radius - CircleRadius) > HULLEPSILON) 238 244 eLog() << Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl; 239 alpha = helper.Angle(& OldSphereCenter);245 alpha = helper.Angle(&RelativeOldSphereCenter); 240 246 // make the angle unique by checking the halfplanes/search direction 241 247 if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON) // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals 242 248 alpha = 2.*M_PI - alpha; 243 //Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " <<OldSphereCenter << " and resulting angle is " << alpha << "." << endl;244 radius = helper.Distance(& OldSphereCenter);249 Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl; 250 radius = helper.Distance(&RelativeOldSphereCenter); 245 251 helper.ProjectOntoPlane(&NormalVector); 246 252 // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles 247 253 if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) { 248 //Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl;254 Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl; 249 255 return alpha; 250 256 } else { 251 //Log() << Verbose(1) << "INFO: NewSphereCenter " << helper << " is too close to OldSphereCenter" <<OldSphereCenter << "." << endl;257 Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl; 252 258 return 2.*M_PI; 253 259 } -
src/vector.cpp
r5e8f82 rb998c3 480 480 else 481 481 return false; 482 }; 483 484 /** Checks whether vector is normal to \a *normal. 485 * @return true - vector is normalized, false - vector is not 486 */ 487 bool Vector::IsEqualTo(const Vector * const a) const 488 { 489 bool status = true; 490 for (int i=0;i<NDIM;i++) { 491 if (fabs(x[i] - a->x[i]) > MYEPSILON) 492 status = false; 493 } 494 return status; 482 495 }; 483 496 -
src/vector.hpp
r5e8f82 rb998c3 42 42 bool IsOne() const; 43 43 bool IsNormalTo(const Vector * const normal) const; 44 bool IsEqualTo(const Vector * const a) const; 44 45 45 46 void AddVector(const Vector * const y);
Note:
See TracChangeset
for help on using the changeset viewer.