- Timestamp:
- Dec 17, 2009, 5:50:04 PM (16 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:
- 1cf5df
- Parents:
- 2130dd (diff), 125b3c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r2130dd r73b510 25 25 26 26 #EXTRA_DIST = ${molecuilder_DATA} 27 28 FORCE: 29 $(srcdir)/.git-version: FORCE 30 @if (test -d $(top_srcdir)/../.git && cd $(srcdir) && git describe HEAD) > .git-version-t 2>/dev/null \ 31 && ! diff .git-version-t $(srcdir)/.git-version >/dev/null 2>&1; then \ 32 mv -f .git-version-t $(srcdir)/.git-version; \ 33 else \ 34 rm -f .git-version-t; \ 35 fi 36 37 EXTRA_DIST = $(srcdir)/.git-version 38 39 $(srcdir)/version.c: $(srcdir)/.git-version 40 echo "const char *ESPACKVersion = \"$(PACKAGE_NAME) -- git version: "`cat $(srcdir)/.git-version`"\";" > $@ 41 42 molecuilder_SOURCES += $(srcdir)/version.c -
src/bondgraph.cpp
r2130dd r73b510 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
r2130dd r73b510 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
r2130dd r73b510 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/builder.cpp
r2130dd r73b510 65 65 #include "molecule.hpp" 66 66 #include "periodentafel.hpp" 67 #include "version.h" 67 68 68 69 /********************************************* Subsubmenu routine ************************************/ … … 2106 2107 if (volume != -1) 2107 2108 ExitFlag = 255; 2108 eLog() << Verbose(0) << "Not enough arguments given for suspension: -u <density>" << endl;2109 eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl; 2109 2110 performCriticalExit(); 2110 2111 } else { … … 2222 2223 int j; 2223 2224 2225 cout << ESPACKVersion << endl; 2226 2224 2227 setVerbosity(0); 2225 2228 -
src/config.cpp
r2130dd r73b510 1074 1074 // don't do this here ... 1075 1075 //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this); 1076 1077 delete(mol); 1076 //delete(mol); 1077 1078 1078 delete(FileBuffer); 1079 1079 }; -
src/molecule_graph.cpp
r2130dd r73b510 1117 1117 bool status = true; 1118 1118 if (ReferenceStack->IsEmpty()) { 1119 eLog() << Verbose(0) << "ReferenceStack is empty!" << endl; 1120 performCriticalExit(); 1119 Log() << Verbose(1) << "ReferenceStack is empty!" << endl; 1121 1120 return false; 1122 1121 } -
src/moleculelist.cpp
r2130dd r73b510 402 402 input.open(line.c_str()); 403 403 if (input == NULL) { 404 eLog() << Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl; 405 performCriticalExit(); 404 Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl; 406 405 return false; 407 406 } -
src/parser.cpp
r2130dd r73b510 158 158 //Log() << Verbose(0) << "Opening " << name << " ... " << input << endl; 159 159 if (input == NULL) { 160 eLog() << Verbose( 0) << endl << "Unable to open " << name << ", is the directory correct?" << endl;161 performCriticalExit();160 eLog() << Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl; 161 //performCriticalExit(); 162 162 return false; 163 163 } -
src/tesselation.cpp
r2130dd r73b510 1587 1587 bool insertNewLine = true; 1588 1588 1589 if (a->lines.find(b->node->nr) != a->lines.end()) { 1590 LineMap::iterator FindLine = a->lines.find(b->node->nr); 1589 LineMap::iterator FindLine = a->lines.find(b->node->nr); 1590 if (FindLine != a->lines.end()) { 1591 Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl; 1592 1591 1593 pair<LineMap::iterator,LineMap::iterator> FindPair; 1592 1594 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 1595 1595 1596 for (FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) { … … 1915 1916 double maxCoordinate[NDIM]; 1916 1917 BoundaryLineSet BaseLine; 1917 Vector Oben;1918 1918 Vector helper; 1919 1919 Vector Chord; 1920 1920 Vector SearchDirection; 1921 1922 Oben.Zero(); 1921 Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers 1922 Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in 1923 Vector SphereCenter; 1924 Vector NormalVector; 1925 1926 NormalVector.Zero(); 1923 1927 1924 1928 for (i = 0; i < 3; i++) { … … 1955 1959 BTS = NULL; 1956 1960 for (int k=0;k<NDIM;k++) { 1957 Oben.Zero();1958 Oben.x[k] = 1.;1961 NormalVector.Zero(); 1962 NormalVector.x[k] = 1.; 1959 1963 BaseLine.endpoints[0] = new BoundaryPointSet(MaxPoint[k]); 1960 1964 Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl; … … 1963 1967 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 1968 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_...1969 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 1970 if (Temporary == NULL) // have we found a second point? 1967 1971 continue; 1968 1972 BaseLine.endpoints[1] = new BoundaryPointSet(Temporary); 1969 1973 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); 1974 // construct center of circle 1975 CircleCenter.CopyVector(BaseLine.endpoints[0]->node->node); 1976 CircleCenter.AddVector(BaseLine.endpoints[1]->node->node); 1977 CircleCenter.Scale(0.5); 1978 1979 // construct normal vector of circle 1980 CirclePlaneNormal.CopyVector(BaseLine.endpoints[0]->node->node); 1981 CirclePlaneNormal.SubtractVector(BaseLine.endpoints[1]->node->node); 1982 1983 double radius = CirclePlaneNormal.NormSquared(); 1984 double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.); 1985 1986 NormalVector.ProjectOntoPlane(&CirclePlaneNormal); 1987 NormalVector.Normalize(); 1976 1988 ShortestAngle = 2.*M_PI; // This will indicate the quadrant. 1977 1989 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) 1990 SphereCenter.CopyVector(&NormalVector); 1991 SphereCenter.Scale(CircleRadius); 1992 SphereCenter.AddVector(&CircleCenter); 1993 // Now, NormalVector and SphereCenter are two orthonormalized vectors in the plane defined by CirclePlaneNormal (not normalized) 1985 1994 1986 1995 // 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 ...1996 SearchDirection.MakeNormalVector(&CirclePlaneNormal, &NormalVector); // whether we look "left" first or "right" first is not important ... 1988 1997 1989 1998 // adding point 1 and point 2 and add the line between them … … 1993 2002 //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << helper << ".\n"; 1994 2003 CandidateForTesselation OptCandidates(&BaseLine); 1995 FindThirdPointForTesselation( Oben, SearchDirection, helper, OptCandidates, NULL, RADIUS, LC);2004 FindThirdPointForTesselation(NormalVector, SearchDirection, SphereCenter, OptCandidates, NULL, RADIUS, LC); 1996 2005 Log() << Verbose(0) << "List of third Points is:" << endl; 1997 2006 for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); it++) { … … 2167 2176 Vector CircleCenter; 2168 2177 Vector CirclePlaneNormal; 2169 Vector OldSphereCenter;2178 Vector RelativeSphereCenter; 2170 2179 Vector SearchDirection; 2171 2180 Vector helper; … … 2174 2183 double radius, CircleRadius; 2175 2184 2176 Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " of triangle " << T << "." << endl;2177 2185 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)) 2186 if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node)) { 2179 2187 ThirdNode = T.endpoints[i]->node; 2188 break; 2189 } 2190 Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdNode " << *ThirdNode << " of triangle " << T << "." << endl; 2180 2191 2181 2192 // construct center of circle … … 2191 2202 radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal); 2192 2203 if (radius/4. < RADIUS*RADIUS) { 2204 // construct relative sphere center with now known CircleCenter 2205 RelativeSphereCenter.CopyVector(&T.SphereCenter); 2206 RelativeSphereCenter.SubtractVector(&CircleCenter); 2207 2193 2208 CircleRadius = RADIUS*RADIUS - radius/4.; 2194 2209 CirclePlaneNormal.Normalize(); 2195 2210 Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 2196 2211 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); 2212 Log() << Verbose(1) << "INFO: OldSphereCenter is at " << T.SphereCenter << "." << endl; 2213 2214 // construct SearchDirection and an "outward pointer" 2215 SearchDirection.MakeNormalVector(&RelativeSphereCenter, &CirclePlaneNormal); 2216 helper.CopyVector(&CircleCenter); 2209 2217 helper.SubtractVector(ThirdNode->node); 2210 2218 if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards! 2211 2219 SearchDirection.Scale(-1.); 2212 SearchDirection.ProjectOntoPlane(&OldSphereCenter);2213 SearchDirection.Normalize();2214 2220 Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 2215 if (fabs( OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {2221 if (fabs(RelativeSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { 2216 2222 // rotated the wrong way! 2217 2223 eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl; … … 2219 2225 2220 2226 // add third point 2221 FindThirdPointForTesselation(T.NormalVector, SearchDirection, OldSphereCenter, CandidateLine, ThirdNode, RADIUS, LC);2227 FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdNode, RADIUS, LC); 2222 2228 2223 2229 } else { … … 2350 2356 AddTesselationPoint((*Sprinter), 2); 2351 2357 2352 Center.CopyVector(&CandidateLine.OptCenter); 2358 2353 2359 // add the lines 2354 2360 AddTesselationLine(TPS[0], TPS[1], 0); … … 2359 2365 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2360 2366 AddTesselationTriangle(); 2361 Center.Scale(-1.); 2367 BTS->GetCenter(&Center); 2368 Center.SubtractVector(&CandidateLine.OptCenter); 2369 BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter); 2362 2370 BTS->GetNormalVector(Center); 2363 2371 … … 2766 2774 Vector NewNormalVector; // normal vector of the Candidate's triangle 2767 2775 Vector helper, OptCandidateCenter, OtherOptCandidateCenter; 2776 Vector RelativeOldSphereCenter; 2777 Vector NewPlaneCenter; 2768 2778 double CircleRadius; // radius of this circle 2769 2779 double radius; 2780 double otherradius; 2770 2781 double alpha, Otheralpha; // angles (i.e. parameter for the circle). 2771 2782 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; … … 2783 2794 CirclePlaneNormal.SubtractVector(CandidateLine.BaseLine->endpoints[1]->node->node); 2784 2795 2796 RelativeOldSphereCenter.CopyVector(&OldSphereCenter); 2797 RelativeOldSphereCenter.SubtractVector(&CircleCenter); 2798 2785 2799 // calculate squared radius TesselPoint *ThirdNode,f circle 2786 radius = CirclePlaneNormal. ScalarProduct(&CirclePlaneNormal);2787 if (radius /4.< RADIUS*RADIUS) {2788 CircleRadius = RADIUS*RADIUS - radius /4.;2800 radius = CirclePlaneNormal.NormSquared()/4.; 2801 if (radius < RADIUS*RADIUS) { 2802 CircleRadius = RADIUS*RADIUS - radius; 2789 2803 CirclePlaneNormal.Normalize(); 2790 //Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;2804 Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 2791 2805 2792 2806 // 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);2807 if (fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) { 2808 eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl; 2809 RelativeOldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal); 2810 } 2811 radius = RelativeOldSphereCenter.NormSquared(); 2798 2812 if (fabs(radius - CircleRadius) < HULLEPSILON) { 2799 //Log() << Verbose(1) << "INFO: OldSphereCenter is at " <<OldSphereCenter << "." << endl;2813 Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl; 2800 2814 2801 2815 // check SearchDirection 2802 //Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;2803 if (fabs( OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { // rotated the wrong way!2816 Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 2817 if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { // rotated the wrong way! 2804 2818 eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl; 2805 2819 } … … 2832 2846 2833 2847 // check for three unique points 2834 Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " at " << *(Candidate->node)<< "." << endl;2848 Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " for BaseLine " << *CandidateLine.BaseLine << " with OldSphereCenter " << OldSphereCenter << "." << endl; 2835 2849 if ((Candidate != CandidateLine.BaseLine->endpoints[0]->node) && (Candidate != CandidateLine.BaseLine->endpoints[1]->node) ){ 2836 2850 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);2840 2841 if ( (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node))2842 && (fabs(NewNormalVector. ScalarProduct(&NewNormalVector)) > HULLEPSILON)2851 // find center on the plane 2852 GetCenterofCircumcircle(&NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node); 2853 Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl; 2854 2855 if (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node) 2856 && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON) 2843 2857 ) { 2844 helper.CopyVector(&NewNormalVector);2845 2858 Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl; 2846 radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewSphereCenter); 2859 radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewPlaneCenter); 2860 Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 2861 Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 2862 Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl; 2847 2863 if (radius < RADIUS*RADIUS) { 2864 otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(&NewPlaneCenter); 2865 if (fabs(radius - otherradius) > HULLEPSILON) { 2866 eLog() << Verbose(1) << "Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius-otherradius) << endl; 2867 } 2868 // construct both new centers 2869 NewSphereCenter.CopyVector(&NewPlaneCenter); 2870 OtherNewSphereCenter.CopyVector(&NewPlaneCenter); 2871 helper.CopyVector(&NewNormalVector); 2848 2872 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;2873 Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl; 2850 2874 NewSphereCenter.AddVector(&helper); 2851 NewSphereCenter.SubtractVector(&CircleCenter);2852 2875 Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl; 2853 2854 2876 // OtherNewSphereCenter is created by the same vector just in the other direction 2855 2877 helper.Scale(-1.); 2856 2878 OtherNewSphereCenter.AddVector(&helper); 2857 OtherNewSphereCenter.SubtractVector(&CircleCenter);2858 2879 Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl; 2859 2880 … … 2861 2882 Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection); 2862 2883 alpha = min(alpha, Otheralpha); 2884 2863 2885 // if there is a better candidate, drop the current list and add the new candidate 2864 2886 // otherwise ignore the new candidate and keep the list … … 2892 2914 } 2893 2915 } 2894 2895 2916 } else { 2896 2917 Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl; … … 4127 4148 Info FunctionInfo(__func__); 4128 4149 4129 /// 1. Find all simply degenerated triangles and sort into a list with each endpoint as key 4130 map<int, int> * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles(); 4131 4132 /// 2. Go through all lines not contained in degenerated triangles. 4133 UniquePolygonSet ListofFours; 4134 UniquePolygonSet TestedPolygons; 4135 for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++) { 4136 Log() << Verbose(1) << "Current Line is: " << *(LineRunner->second) << endl; 4137 4138 BoundaryPolygonSet *Four = new BoundaryPolygonSet; 4139 4140 /// 2a. Get all four endpoints of the two connected triangles. 4141 Four->FillPolygonFromTrianglesOfLine((LineRunner->second)); 4142 if (Four->endpoints.size() != 4) { 4143 Log() << Verbose(0) << "REJECT: There were no four endpoints:" << *Four << endl; 4144 delete(Four); 4145 continue; 4146 } 4147 4148 /// 2b. Get the triangles of all those endpoints 4149 TriangleSet *T = Four->GetAllContainedTrianglesFromEndpoints(); 4150 4151 /// 2c1. Check whether all triangles have (besides sign) same normal vector) 4152 TriangleSet::const_iterator Runner = T->begin(); 4153 Vector NormalVector; 4154 NormalVector.CopyVector(&(*Runner)->NormalVector); 4155 Runner++; 4156 bool IsPlanar = true; 4157 for (; Runner != T->end(); Runner++) { 4158 if (fabs(fabs(NormalVector.ScalarProduct(&(*Runner)->NormalVector)) - 1.) > MYEPSILON) // check whether all NormalVectors are parallel 4159 IsPlanar = false; 4160 } 4161 4162 /// 2c2. check whether triangles are not already simply degenerated. 4163 size_t DegeneratedCount = 0; 4164 for (TriangleSet::const_iterator Runner = T->begin(); Runner != T->end(); Runner++) { 4165 if (SimplyDegeneratedTriangles->find((*Runner)->Nr) != SimplyDegeneratedTriangles->end()) 4166 DegeneratedCount++; 4167 } 4168 Log() << Verbose(1) << "Found " << DegeneratedCount << " degenerated triangles." << endl; 4169 4170 if (IsPlanar) { 4171 if(DegeneratedCount == 0) { 4172 /// 2c. Find all pairs of those triangles that contain the four endpoints 4173 const int counter = CountTrianglePairContainingPolygon(Four, T); 4174 Log() << Verbose(1) << "There are " << counter << " pairs for this polygon of four." << endl; 4175 if (counter %3 == 0) { 4176 /// 2d. Check the number of pairs, if greater 1, we have a degenerated polygon (mark down for later use) 4177 pair < UniquePolygonSet::iterator, bool > Tester = ListofFours.insert(Four); 4178 if (Tester.second) { 4179 Log() << Verbose(0) << "ACCEPT: We have a degenerated polygon." << *Four << endl; 4180 } else { 4181 Log() << Verbose(0) << "REJECT: Degenerated polygon already present." << *Four << endl; 4182 delete(Four); 4150 /// 2. Go through all BoundaryPointSet's, check their triangles' NormalVector 4151 map <int, int> *DegeneratedTriangles = FindAllDegeneratedTriangles(); 4152 set < BoundaryPointSet *> EndpointCandidateList; 4153 pair < set < BoundaryPointSet *>::iterator, bool > InsertionTester; 4154 pair < map < int, Vector *>::iterator, bool > TriangleInsertionTester; 4155 for (PointMap::const_iterator Runner = PointsOnBoundary.begin(); Runner != PointsOnBoundary.end(); Runner++) { 4156 Log() << Verbose(0) << "Current point is " << *Runner->second << "." << endl; 4157 map < int, Vector *> TriangleVectors; 4158 // gather all NormalVectors 4159 Log() << Verbose(1) << "Gathering triangles ..." << endl; 4160 for (LineMap::const_iterator LineRunner = (Runner->second)->lines.begin(); LineRunner != (Runner->second)->lines.end(); LineRunner++) 4161 for (TriangleMap::const_iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) { 4162 if (DegeneratedTriangles->find(TriangleRunner->second->Nr) == DegeneratedTriangles->end()) { 4163 TriangleInsertionTester = TriangleVectors.insert( pair< int, Vector *> ((TriangleRunner->second)->Nr, &((TriangleRunner->second)->NormalVector)) ); 4164 if (TriangleInsertionTester.second) 4165 Log() << Verbose(1) << " Adding triangle " << *(TriangleRunner->second) << " to triangles to check-list." << endl; 4166 } else { 4167 Log() << Verbose(1) << " NOT adding triangle " << *(TriangleRunner->second) << " as it's a simply degenerated one." << endl; 4168 } 4169 } 4170 // check whether there are two that are parallel 4171 Log() << Verbose(1) << "Finding two parallel triangles ..." << endl; 4172 for (map < int, Vector *>::iterator VectorWalker = TriangleVectors.begin(); VectorWalker != TriangleVectors.end(); VectorWalker++) 4173 for (map < int, Vector *>::iterator VectorRunner = VectorWalker; VectorRunner != TriangleVectors.end(); VectorRunner++) 4174 if (VectorWalker != VectorRunner) { // skip equals 4175 const double SCP = VectorWalker->second->ScalarProduct(VectorRunner->second); // ScalarProduct should result in -1. for degenerated triangles 4176 Log() << Verbose(1) << "Checking " << *VectorWalker->second<< " against " << *VectorRunner->second << ": " << SCP << endl; 4177 if (fabs(SCP + 1.) < ParallelEpsilon) { 4178 InsertionTester = EndpointCandidateList.insert((Runner->second)); 4179 if (InsertionTester.second) 4180 Log() << Verbose(0) << " Adding " << *Runner->second << " to endpoint candidate list." << endl; 4181 // and break out of both loops 4182 VectorWalker = TriangleVectors.end(); 4183 VectorRunner = TriangleVectors.end(); 4184 break; 4183 4185 } 4186 } 4187 } 4188 4189 /// 3. Find connected endpoint candidates and put them into a polygon 4190 UniquePolygonSet ListofDegeneratedPolygons; 4191 BoundaryPointSet *Walker = NULL; 4192 BoundaryPointSet *OtherWalker = NULL; 4193 BoundaryPolygonSet *Current = NULL; 4194 stack <BoundaryPointSet*> ToCheckConnecteds; 4195 while (!EndpointCandidateList.empty()) { 4196 Walker = *(EndpointCandidateList.begin()); 4197 if (Current == NULL) { // create a new polygon with current candidate 4198 Log() << Verbose(0) << "Starting new polygon set at point " << *Walker << endl; 4199 Current = new BoundaryPolygonSet; 4200 Current->endpoints.insert(Walker); 4201 EndpointCandidateList.erase(Walker); 4202 ToCheckConnecteds.push(Walker); 4203 } 4204 4205 // go through to-check stack 4206 while (!ToCheckConnecteds.empty()) { 4207 Walker = ToCheckConnecteds.top(); // fetch ... 4208 ToCheckConnecteds.pop(); // ... and remove 4209 for (LineMap::const_iterator LineWalker = Walker->lines.begin(); LineWalker != Walker->lines.end(); LineWalker++) { 4210 OtherWalker = (LineWalker->second)->GetOtherEndpoint(Walker); 4211 Log() << Verbose(1) << "Checking " << *OtherWalker << endl; 4212 set < BoundaryPointSet *>::iterator Finder = EndpointCandidateList.find(OtherWalker); 4213 if (Finder != EndpointCandidateList.end()) { // found a connected partner 4214 Log() << Verbose(1) << " Adding to polygon." << endl; 4215 Current->endpoints.insert(OtherWalker); 4216 EndpointCandidateList.erase(Finder); // remove from candidates 4217 ToCheckConnecteds.push(OtherWalker); // but check its partners too 4184 4218 } else { 4185 Log() << Verbose(0) << "REJECT: Seems to be the edge line of a degenerated polygon only." << *Four << endl; 4186 delete(Four); 4219 Log() << Verbose(1) << " is not connected to " << *Walker << endl; 4187 4220 } 4188 } else {4189 Log() << Verbose(0) << "REJECT: This polygon contains some simply degenerated triangles." << endl;4190 delete(Four);4191 4221 } 4192 } else { 4193 Log() << Verbose(0) << "REJECT: This polygon does not lay on a plane." << endl; 4194 delete(Four); 4195 } 4196 4197 delete(T); 4198 } 4199 4200 /// 3. Combine all edge-connected degenerated polygons 4201 { 4202 UniquePolygonSet::iterator PolygonWalker; // is the inner iterator 4203 UniquePolygonSet::iterator PolygonSprinter; // is the inner advanced iterator 4204 for (UniquePolygonSet::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) { 4205 const BoundaryPolygonSet *P1 = *PolygonRunner; 4206 Log() << Verbose(1) << "Current Polygon is : " << *P1 << endl; 4207 PolygonWalker = PolygonRunner; 4208 PolygonWalker++; 4209 PolygonSprinter = PolygonWalker; 4210 while (PolygonWalker != ListofFours.end()) { 4211 BoundaryPolygonSet *P2 = *PolygonWalker; 4212 Log() << Verbose(1) << "Current Other Polygon is : " << *P2 << endl; 4213 PolygonSprinter++; 4214 Log() << Verbose(1) << "Are " << *P1 << " and " << *P2 << " edge-connected?" << endl; 4215 if (ArePolygonsEdgeConnected((*PolygonRunner), (P2))) { // if connected 4216 Log() << Verbose(0) << "Yes!" << endl; 4217 CombinePolygons((*PolygonRunner), (P2)); // combined and ... 4218 ListofFours.erase(PolygonWalker); // ... remove from list 4219 Log() << Verbose(1) << " New current Polygon is : " << *P1 << endl; 4220 } else { 4221 Log() << Verbose(0) << "No." << endl; 4222 } 4223 PolygonWalker = PolygonSprinter; 4224 } 4225 } 4226 } 4227 4228 Log() << Verbose(0) << "The following degenerated polygons have been found: " << endl; 4229 for (UniquePolygonSet::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) 4222 } 4223 4224 Log() << Verbose(0) << "Final polygon is " << *Current << endl; 4225 ListofDegeneratedPolygons.insert(Current); 4226 Current = NULL; 4227 } 4228 4229 const int counter = ListofDegeneratedPolygons.size(); 4230 4231 Log() << Verbose(0) << "The following " << counter << " degenerated polygons have been found: " << endl; 4232 for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++) 4230 4233 Log() << Verbose(0) << " " << **PolygonRunner << endl; 4231 4234 4232 4235 /// 4. Go through all these degenerated polygons 4233 for (UniquePolygonSet::iterator PolygonRunner = Listof Fours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) {4236 for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++) { 4234 4237 stack <int> TriangleNrs; 4235 4238 Vector NormalVector; 4236 4239 /// 4a. Gather all triangles of this polygon 4237 4240 TriangleSet *T = (*PolygonRunner)->GetAllContainedTrianglesFromEndpoints(); 4241 4242 // check whether number is bigger than 2, otherwise it's just a simply degenerated one and nothing to do. 4243 if (T->size() == 2) { 4244 Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl; 4245 delete(T); 4246 continue; 4247 } 4248 4249 // check whether number is even 4250 // If this case occurs, we have to think about it! 4251 // The Problem is probably due to two degenerated polygons being connected by a bridging, non-degenerated polygon, as somehow one node has 4252 // connections to either polygon ... 4253 if (T->size() % 2 != 0) { 4254 eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl; 4255 performCriticalExit(); 4256 } 4238 4257 4239 4258 TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator … … 4261 4280 TriangleWalker = T->begin(); 4262 4281 while (TriangleWalker != T->end()) { // go through all front triangles 4263 Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << BTS->NormalVector << endl;4282 Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << (*TriangleWalker)->NormalVector << endl; 4264 4283 for (int i = 0; i < 3; i++) 4265 4284 AddTesselationPoint((*TriangleWalker)->endpoints[i]->node, i); … … 4267 4286 AddTesselationLine(TPS[0], TPS[2], 1); 4268 4287 AddTesselationLine(TPS[1], TPS[2], 2); 4288 if (TriangleNrs.empty()) 4289 eLog() << Verbose(0) << "No more free triangle numbers!" << endl; 4269 4290 BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ... 4270 4291 AddTesselationTriangle(); // ... and add … … 4272 4293 BTS->NormalVector.CopyVector(&(*TriangleWalker)->NormalVector); 4273 4294 BTS->NormalVector.Scale(-1.); 4274 /// 4d. Add all degenerated triangles to the list of simply degenerated triangles4275 SimplyDegeneratedTriangles->insert(pair <int, int> ((*TriangleWalker)->Nr, BTS->Nr) );4276 SimplyDegeneratedTriangles->insert(pair <int, int> (BTS->Nr, (*TriangleWalker)->Nr) );4277 4295 TriangleWalker++; 4278 4296 } … … 4283 4301 } 4284 4302 4303 map<int, int> * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles(); 4285 4304 Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl; 4286 4305 map<int,int>::iterator it; 4287 4306 for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++) 4288 4307 Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl; 4308 delete(SimplyDegeneratedTriangles); 4289 4309 4290 4310 /// 5. exit 4291 4311 UniquePolygonSet::iterator PolygonRunner; 4292 while (!Listof Fours.empty()) {4293 PolygonRunner = Listof Fours.begin();4312 while (!ListofDegeneratedPolygons.empty()) { 4313 PolygonRunner = ListofDegeneratedPolygons.begin(); 4294 4314 delete(*PolygonRunner); 4295 ListofFours.erase(PolygonRunner); 4296 } 4297 4298 const int counter = SimplyDegeneratedTriangles->size(); 4299 delete(SimplyDegeneratedTriangles); 4315 ListofDegeneratedPolygons.erase(PolygonRunner); 4316 } 4317 4300 4318 return counter; 4301 4319 }; -
src/tesselation.hpp
r2130dd r73b510 47 47 #define Raster3DSuffix ".r3d" 48 48 #define VRMLSUffix ".wrl" 49 50 #define ParallelEpsilon 1e-3 49 51 50 52 // ======================================================= some template functions ========================================= … … 156 158 class BoundaryLineSet *lines[3]; 157 159 Vector NormalVector; 160 Vector SphereCenter; 158 161 int Nr; 159 162 }; -
src/tesselationhelpers.cpp
r2130dd r73b510 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
r2130dd r73b510 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
r2130dd r73b510 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.