Changeset 32d7e4
- Timestamp:
- Oct 19, 2014, 5:13:10 PM (10 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:
- d45a5b
- Parents:
- d33bb8
- git-author:
- Frederik Heber <heber@…> (10/07/14 06:57:30)
- git-committer:
- Frederik Heber <heber@…> (10/19/14 17:13:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tesselation/tesselation.cpp
rd33bb8 r32d7e4 1902 1902 class BoundaryLineSet *OldLines[4], *NewLine; 1903 1903 class BoundaryPointSet *OldPoints[2]; 1904 Vector BaseLineNormal; 1904 Vector BaseLineNormal[2]; 1905 Vector OtherEndpoint[2]; // fourth point to either triangle 1905 1906 int OldTriangleNrs[2], OldBaseLineNr; 1906 1907 int i, m; 1907 1908 1908 1909 // calculate NormalVector for later use 1909 BaseLineNormal.Zero();1910 1910 if (Base->triangles.size() < 2) { 1911 1911 ELOG(1, "Less than two triangles are attached to this baseline!"); 1912 1912 return NULL; 1913 1913 } 1914 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 1915 LOG(5, "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "."); 1916 BaseLineNormal += (runner->second->NormalVector); 1917 } 1918 BaseLineNormal.Scale(-1. / 2.); // has to point inside for BoundaryTriangleSet::GetNormalVector() 1914 { 1915 int i=0; 1916 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 1917 LOG(5, "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "."); 1918 OtherEndpoint[(i+1)%2] = runner->second->GetThirdEndpoint(Base)->node->getPosition(); 1919 BaseLineNormal[i++] = (runner->second->NormalVector); 1920 ASSERT( i <= 2, 1921 "Tesselation::FlipBaseline() - not exactly two triangles found."); 1922 } 1923 } 1919 1924 1920 1925 // get the two triangles … … 1946 1951 1947 1952 // index OldLines and OldPoints 1953 // note that oldlines[0,1] belong to first triangle and hence first normal 1954 // vector and oldlines[2,3] belong to second triangle and its normal vector 1948 1955 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) 1949 1956 for (int j = 0; j < 3; j++) // all of their endpoints and baselines … … 1955 1962 OldPoints[m++] = runner->second->endpoints[j]; 1956 1963 1964 Vector BasePoints[2]; // endpoints of Base 1965 if (OldLines[0]->ContainsBoundaryPoint(Base->endpoints[0])) { 1966 BasePoints[0] = Base->endpoints[0]->node->getPosition(); 1967 BasePoints[1] = Base->endpoints[1]->node->getPosition(); 1968 } else { 1969 BasePoints[0] = Base->endpoints[1]->node->getPosition(); 1970 BasePoints[1] = Base->endpoints[0]->node->getPosition(); 1971 } 1957 1972 // check whether everything is in place to create new lines and triangles 1958 1973 if (i < 4) { … … 1970 1985 return NULL; 1971 1986 } 1987 1988 // construct plane of first triangle for calculating normal vectors later 1989 const Plane triangleplane = Base->triangles.begin()->second->getPlane(); 1990 // get fourth point projected down onto this plane 1991 const Vector Intersection = triangleplane.getClosestPoint(OtherEndpoint[0]); 1972 1992 1973 1993 // remove triangles and baseline removes itself … … 1994 2014 LOG(3, "DEBUG: Created new baseline " << *NewLine << "."); 1995 2015 2016 // Explanation for normal vector choice: 2017 // Decisive for the normal vector of the new triangle is whether the fourth 2018 // endpoint is with respect to the joining boundary line on one side or on 2019 // the other with respect to the endpoint of the plane triangle that is not 2020 // contained in the joining boundary line. 2021 1996 2022 // construct new triangles with flipped baseline 1997 2023 i = -1; … … 2005 2031 BLS[2] = NewLine; 2006 2032 BTS = new class BoundaryTriangleSet(BLS, OldTriangleNrs[0]); 2007 BTS->GetNormalVector(BaseLineNormal); 2033 { 2034 Line joiningline = makeLineThrough( 2035 OldLines[0]->endpoints[0]->node->getPosition(), 2036 OldLines[0]->endpoints[1]->node->getPosition()); 2037 // BasePoints[1] is not contained in OldLines[0], hence is third endpoint 2038 // of plane triangle. BasePoints[0] is in the joining OldLines[0] and 2039 // we check whether Intersection is on same side as BasePoints[1] or not. 2040 const Vector pointinginside = 2041 joiningline.getClosestPoint(BasePoints[1]) - BasePoints[1]; 2042 const Vector pointingtointersection = 2043 joiningline.getClosestPoint(Intersection) - Intersection; 2044 const double sign_of_intersection = 2045 pointingtointersection.ScalarProduct(pointinginside); 2046 LOG(4, "DEBUG: Sign of SKP between both lines w.r.t " << *OldLines[0] 2047 << " is " << sign_of_intersection << "."); 2048 const double sign_of_normal = (sign_of_intersection >= 0) ? -1. : +1.; 2049 LOG(4, "DEBUG: Opposite normal direction is " 2050 << sign_of_normal * BaseLineNormal[0] << "."); 2051 BTS->GetNormalVector(sign_of_normal * BaseLineNormal[0]); 2052 } 2008 2053 AddTesselationTriangle(OldTriangleNrs[0]); 2009 2054 LOG(3, "DEBUG: Created new triangle " << *BTS << "."); … … 2013 2058 BLS[2] = NewLine; 2014 2059 BTS = new class BoundaryTriangleSet(BLS, OldTriangleNrs[1]); 2015 BTS->GetNormalVector(BaseLineNormal); 2060 { 2061 Line joiningline = makeLineThrough( 2062 OldLines[1]->endpoints[0]->node->getPosition(), 2063 OldLines[1]->endpoints[1]->node->getPosition()); 2064 // BasePoints[0] is not contained in OldLines[1], hence is third endpoint 2065 // of plane triangle. BasePoints[1] is in th1e joining OldLines[1] and 2066 // we check whether Intersection is on same side as BasePoints[0] or not. 2067 const Vector pointinginside = 2068 joiningline.getClosestPoint(BasePoints[0]) - BasePoints[0]; 2069 const Vector pointingtointersection = 2070 joiningline.getClosestPoint(Intersection) - Intersection; 2071 const double sign_of_intersection = 2072 pointingtointersection.ScalarProduct(pointinginside); 2073 LOG(4, "DEBUG: Sign of SKP between both lines w.r.t " << *OldLines[1] 2074 << " is " << sign_of_intersection << "."); 2075 const double sign_of_normal = (sign_of_intersection >= 0) ? -1. : +1.; 2076 LOG(4, "DEBUG: Opposite normal direction is " 2077 << sign_of_normal * BaseLineNormal[0] << "."); 2078 BTS->GetNormalVector(sign_of_normal * BaseLineNormal[0]); 2079 } 2016 2080 AddTesselationTriangle(OldTriangleNrs[1]); 2017 2081 LOG(3, "DEBUG: Created new triangle " << *BTS << ".");
Note:
See TracChangeset
for help on using the changeset viewer.