// File: TangentZone.cxx // Created: Mon Jun 24 10:07:47 1991 // Author: Didier PIFFAULT // #include #define DEBUG_TANGENTZONE 0 //======================================================================= //function : Intf_TangentZone //purpose : Constructor of an empty tangent zone. //======================================================================= Intf_TangentZone::Intf_TangentZone () { ParamOnFirstMin = ParamOnSecondMin = RealLast(); ParamOnFirstMax = ParamOnSecondMax = RealFirst(); } //======================================================================= //function : Intf_TangentZone //purpose : Copy //======================================================================= Intf_TangentZone::Intf_TangentZone (const Intf_TangentZone& Other) { Result=Other.Result; ParamOnFirstMin = Other.ParamOnFirstMin; ParamOnFirstMax = Other.ParamOnFirstMax; ParamOnSecondMin = Other.ParamOnSecondMin; ParamOnSecondMax = Other.ParamOnSecondMax; } //======================================================================= //function : Append //purpose : Append the section point to the tangent zone. //======================================================================= void Intf_TangentZone::Append (const Intf_SectionPoint& Pi) { Result.Append(Pi); if(ParamOnFirstMin > Pi.ParamOnFirst()) ParamOnFirstMin = Pi.ParamOnFirst(); if(ParamOnSecondMin > Pi.ParamOnSecond()) ParamOnSecondMin = Pi.ParamOnSecond(); if(ParamOnFirstMax < Pi.ParamOnFirst()) ParamOnFirstMax = Pi.ParamOnFirst(); if(ParamOnSecondMax < Pi.ParamOnSecond()) ParamOnSecondMax = Pi.ParamOnSecond(); } //======================================================================= //function : Append //purpose : Merge the TangentZone to the tangent zone. //======================================================================= void Intf_TangentZone::Append (const Intf_TangentZone& Tzi) { Standard_Integer Tzi_NumberOfPoints = Tzi.NumberOfPoints(); for (Standard_Integer ipi=1; ipi<=Tzi_NumberOfPoints; ipi++) { PolygonInsert(Tzi.GetPoint(ipi)); } } //======================================================================= //function : Insert //purpose : Insert the section point at his place in the tangent zone. //======================================================================= //Standard_Boolean Intf_TangentZone::Insert (const Intf_SectionPoint& Pi) Standard_Boolean Intf_TangentZone::Insert (const Intf_SectionPoint& ) { #if DEBUG_TANGENTZONE cout<<" Standard_Boolean Intf_TangentZone::Insert (const Intf_SectionPoint& Pi) ???? "<0) { InsertAfter(lpon, Pi); Inserted=Standard_True; } */ return Inserted; } //======================================================================= //function : PolygonInsert //purpose : Insert the point at his place in the polygonal tangent zone. //======================================================================= void Intf_TangentZone::PolygonInsert (const Intf_SectionPoint& Pi) { // Standard_Boolean Inserted=Standard_False; Standard_Integer nbpTz=NumberOfPoints(); // Standard_Integer lpi; if(nbpTz==0) { Append(Pi); return; } if(Pi.ParamOnFirst() >= ParamOnFirstMax) { Append(Pi); } else if(Pi.ParamOnFirst() >= ParamOnFirstMin) { InsertBefore(1,Pi); } else { /*----- Trop Long lbr le 13 mai 97 Standard_Real PiParamOnFirst = Pi.ParamOnFirst(); Standard_Real PiParamOnSecond = Pi.ParamOnSecond(); for (lpi=1; lpi<=nbpTz; lpi++) { const Intf_SectionPoint& Resultlpi = Result(lpi); if (PiParamOnFirst Pi.ParamOnFirst()) ParamOnFirstMin = Pi.ParamOnFirst(); if(ParamOnSecondMin > Pi.ParamOnSecond()) ParamOnSecondMin = Pi.ParamOnSecond(); if(ParamOnFirstMax < Pi.ParamOnFirst()) ParamOnFirstMax = Pi.ParamOnFirst(); if(ParamOnSecondMax < Pi.ParamOnSecond()) ParamOnSecondMax = Pi.ParamOnSecond(); } //======================================================================= //function : InsertBefore //purpose : //======================================================================= void Intf_TangentZone::InsertBefore(const Standard_Integer Index, const Intf_SectionPoint& Pi) { Result.InsertBefore(Index, Pi); if(ParamOnFirstMin > Pi.ParamOnFirst()) ParamOnFirstMin = Pi.ParamOnFirst(); if(ParamOnSecondMin > Pi.ParamOnSecond()) ParamOnSecondMin = Pi.ParamOnSecond(); if(ParamOnFirstMax < Pi.ParamOnFirst()) ParamOnFirstMax = Pi.ParamOnFirst(); if(ParamOnSecondMax < Pi.ParamOnSecond()) ParamOnSecondMax = Pi.ParamOnSecond(); } //======================================================================= //function : GetPoint //purpose : Return the section point of range index in the tangent zone. //======================================================================= const Intf_SectionPoint& Intf_TangentZone::GetPoint (const Standard_Integer Index) const { return Result(Index); } //======================================================================= //function : IsEqual //purpose : Compare two tangent zone. //======================================================================= Standard_Boolean Intf_TangentZone::IsEqual (const Intf_TangentZone& Other) const { if (Result.Length() != Other.Result.Length()) return Standard_False; Standard_Integer i; for (i = 1; i <= Result.Length(); i++) { if (!Result(i).IsEqual(Other.Result(i))) return Standard_False; } return Standard_True; } //======================================================================= //function : Contains //purpose : //======================================================================= Standard_Boolean Intf_TangentZone::Contains (const Intf_SectionPoint& ThePI) const { Standard_Integer i; for (i = 1; i <= Result.Length(); i++) if (ThePI.IsEqual(Result(i))) return Standard_True; return Standard_False; } //======================================================================= //function : InfoFirst //purpose : //======================================================================= void Intf_TangentZone::InfoFirst(Standard_Integer& segMin, Standard_Real& paraMin, Standard_Integer& segMax, Standard_Real& paraMax) const { ParamOnFirst(paraMin, paraMax); segMin = (Standard_Integer)(IntegerPart(paraMin)); paraMin = paraMin-(Standard_Real)segMin; segMax = (Standard_Integer)(IntegerPart(paraMax)); paraMax = paraMax-(Standard_Real)segMax; } //======================================================================= //function : InfoSecond //purpose : //======================================================================= void Intf_TangentZone::InfoSecond(Standard_Integer& segMin, Standard_Real& paraMin, Standard_Integer& segMax, Standard_Real& paraMax) const { ParamOnSecond(paraMin, paraMax); segMin = (Standard_Integer)(IntegerPart(paraMin)); paraMin = paraMin-(Standard_Real)segMin; segMax = (Standard_Integer)(IntegerPart(paraMax)); paraMax = paraMax-(Standard_Real)segMax; } //======================================================================= //function : RangeContains //purpose : //======================================================================= Standard_Boolean Intf_TangentZone::RangeContains (const Intf_SectionPoint& ThePI) const { Standard_Real a, b, c, d; ParamOnFirst(a, b); ParamOnSecond(c, d); if (a<=ThePI.ParamOnFirst() && ThePI.ParamOnFirst()<=b && c<=ThePI.ParamOnSecond()&& ThePI.ParamOnSecond()<=d ) return Standard_True; return Standard_False; } //======================================================================= //function : HasCommonRange //purpose : //======================================================================= Standard_Boolean Intf_TangentZone::HasCommonRange (const Intf_TangentZone& Other) const { Standard_Real a1,b1,c1,d1; Standard_Real a2,b2,c2,d2; ParamOnFirst(a1, b1); ParamOnSecond(a2, b2); Other.ParamOnFirst(c1, d1); Other.ParamOnSecond(c2, d2); if (((c1<=a1 && a1<=d1) || (c1<=b1 && b1<=d1) || (a1<=c1 && c1<=b1)) && ((c2<=a2 && a2<=d2) || (c2<=b2 && b2<=d2) || (a2<=c2 && c2<=b2))) return Standard_True; return Standard_False; } //======================================================================= //function : Dump //purpose : Dump the TangentZone. //======================================================================= void Intf_TangentZone::Dump (const Standard_Integer Indent ) const { #if DEBUG_TANGENTZONE for (Standard_Integer id=0; id