32 TEveShape::TEveShape(
const char* n,
const char* t) :
33 TEveElementList(n, t),
38 fHighlightFrame(kFALSE),
41 fCanEditMainColor = kTRUE;
42 fCanEditMainTransparency = kTRUE;
43 SetMainColorPtr(&fFillColor);
49 TEveShape::~TEveShape()
58 void TEveShape::SetMainColor(Color_t color)
60 if (fFillColor == fLineColor) {
64 TEveElementList::SetMainColor(color);
70 void TEveShape::CopyVizParams(
const TEveElement* el)
72 const TEveShape* m =
dynamic_cast<const TEveShape*
>(el);
75 fFillColor = m->fFillColor;
76 fLineColor = m->fLineColor;
77 fLineWidth = m->fLineWidth;
78 fDrawFrame = m->fDrawFrame;
79 fHighlightFrame = m->fHighlightFrame;
80 fMiniFrame = m->fMiniFrame;
83 TEveElementList::CopyVizParams(el);
89 void TEveShape::WriteVizParams(std::ostream& out,
const TString& var)
91 TEveElementList::WriteVizParams(out, var);
93 TString t =
" " + var +
"->";
94 out << t <<
"SetFillColor(" << fFillColor <<
");\n";
95 out << t <<
"SetLineColor(" << fLineColor <<
");\n";
96 out << t <<
"SetLineWidth(" << fLineWidth <<
");\n";
97 out << t <<
"SetDrawFrame(" << ToString(fDrawFrame) <<
");\n";
98 out << t <<
"SetHighlightFrame(" << ToString(fHighlightFrame) <<
");\n";
104 void TEveShape::Paint(Option_t*)
117 Int_t TEveShape::FindConvexHull(
const vVector2_t& pin, vVector2_t& pout, TEveElement* caller)
119 Int_t N = pin.size();
123 for (Int_t i = 1; i < N; ++i)
125 if (pin[i].fY < pin[min_point].fY || (pin[i].fY == pin[min_point].fY && pin[i].fX < pin[min_point].fX))
130 std::vector<Float_t> angles(N);
131 for (Int_t i = 0; i < N; ++i)
133 angles[i] = (pin[i] - pin[min_point]).Phi();
135 std::vector<Int_t> idcs(N);
136 TMath::Sort(N, &angles[0], &idcs[0], kFALSE);
142 std::vector<Int_t> new_idcs;
143 new_idcs.push_back(idcs[0]);
144 std::vector<Int_t>::iterator a, b;
145 a = idcs.begin(); ++a;
147 while (b != idcs.end())
149 if (TMath::Abs(angles[*a] - angles[*b]) < 1e-5f)
151 if (pin[idcs[0]].SquareDistance(pin[*a]) < pin[idcs[0]].SquareDistance(pin[*b]))
156 new_idcs.push_back(*a);
161 new_idcs.push_back(*a);
168 std::vector<Int_t> hull;
171 hull.push_back(idcs[0]);
172 hull.push_back(idcs[1]);
173 hull.push_back(idcs[2]);
178 Int_t n = hull.size() - 1;
179 if ((pin[hull[n]] - pin[hull[n-1]]).Cross(pin[idcs[i]] - pin[hull[n]]) > 0)
181 hull.push_back(idcs[i]);
193 ::Warning(
"TEveShape::FindConvexHull()",
"Polygon reduced to %d points. for '%s'.",
194 N, caller ? caller->GetElementName() :
"unknown");
200 Int_t Nold = pout.size();
201 pout.resize(Nold + N);
202 for (Int_t i = 0; i < N; ++i)
204 pout[Nold + i] = pin[hull[i]];
222 Bool_t TEveShape::IsBoxOrientationConsistentEv(
const TEveVector box[8])
224 TEveVector f1 = box[1] - box[0];
225 TEveVector f2 = box[3] - box[0];
226 TEveVector up = box[4] - box[0];
228 return up.Dot(f1.Cross(f2)) < 0;
236 Bool_t TEveShape::IsBoxOrientationConsistentFv(
const Float_t box[8][3])
238 TEveVector b0(box[0]);
239 TEveVector f1(box[1]); f1 -= b0;
240 TEveVector f2(box[3]); f2 -= b0;
241 TEveVector up(box[4]); up -= b0;
243 return up.Dot(f1.Cross(f2)) < 0;
249 void TEveShape::CheckAndFixBoxOrientationEv(TEveVector box[8])
251 if ( ! IsBoxOrientationConsistentEv(box))
253 std::swap(box[1], box[3]);
254 std::swap(box[5], box[7]);
261 void TEveShape::CheckAndFixBoxOrientationFv(Float_t box[8][3])
263 if ( ! IsBoxOrientationConsistentFv(box))
265 std::swap(box[1][0], box[3][0]);
266 std::swap(box[1][1], box[3][1]);
267 std::swap(box[1][2], box[3][2]);
268 std::swap(box[5][0], box[7][0]);
269 std::swap(box[5][1], box[7][1]);
270 std::swap(box[5][2], box[7][2]);