35 Seg_t(
Int_t i1=-1,
Int_t i2=-1) : fV1(i1), fV2(i2) {}
38 typedef std::list<Seg_t> LSeg_t;
53REvePolygonSetProjected::REvePolygonSetProjected(
const std::string &
n,
const std::string &t) :
75 j[
"fNPnts"] =
fPnts.size();
90 fRenderData = std::make_unique<REveRenderData>(
"makePolygonSetProjected", 3 *
fPnts.size());
93 Int_t n_poly_info = 0;
94 for (
auto &p :
fPols) n_poly_info += 1 + p.NPoints();
96 std::vector<Double_t> verts;
97 verts.reserve(3 *
fPnts.size());
98 std::vector<Int_t>
polys;
99 polys.reserve(n_poly_info);
101 for (
auto &p :
fPols)
103 polys.emplace_back(p.NPoints());
104 polys.insert(
polys.end(), p.fPnts.begin(), p.fPnts.end());
107 for (
unsigned i = 0; i <
fPnts.size(); ++i)
109 verts.push_back(
fPnts[i].fX);
110 verts.push_back(
fPnts[i].fY);
111 verts.push_back(
fPnts[i].fZ);
126 Int_t n_idxbuff = 2 + 3 * n_trings + n_pols + n_poly_info;
129 assert(n_trings * 4 == (
int)
polys.size());
134 for (
int i = 0; i < n_trings; ++i)
142 for (
auto &p :
fPols)
157 if (
fPnts.size() > 0) {
186 for (
unsigned i = 0; i <
fPnts.size(); ++i)
221 std::vector<REveVector> pnts; pnts.resize(buffN);
222 for (
Int_t i = 0; i < buffN; ++i)
224 pnts[i].Set(
fBuff->fPnts[3*i],
fBuff->fPnts[3*i+1],
fBuff->fPnts[3*i+2]);
225 projection->
ProjectPoint(pnts[i].fX, pnts[i].fY, pnts[i].fZ, 0,
230 std::vector<Int_t> idxMap;
231 idxMap.resize(buffN);
238 for (
Int_t k = 0; k < npoints; ++k)
256 fPnts.resize(npoints);
257 for (
Int_t idx = 0; idx < npoints; ++idx)
262 fPnts[idx].Set(pnts[i]);
275 if (pp.size() <= 2)
return 0;
277 Float_t bbox[4] = { 1e6, -1e6, 1e6, -1e6 };
280 if (
fPnts[idx].fX < bbox[0]) bbox[0] =
fPnts[idx].fX;
281 if (
fPnts[idx].fX > bbox[1]) bbox[1] =
fPnts[idx].fX;
283 if (
fPnts[idx].fY < bbox[2]) bbox[2] =
fPnts[idx].fY;
284 if (
fPnts[idx].fY > bbox[3]) bbox[3] =
fPnts[idx].fY;
287 if ((bbox[1]-bbox[0]) < eps || (bbox[3]-bbox[2]) < eps)
return 0;
290 for (
auto &&refP : pols)
292 if ((
Int_t) pp.size() != refP.NPoints())
295 Int_t start_idx = refP.FindPoint(pp.front());
298 if (++start_idx >= refP.NPoints()) start_idx = 0;
302 auto u = ++pp.begin();
303 Int_t pidx = start_idx;
304 while (u != pp.end())
306 if ((*u) != refP.fPnts[pidx])
309 if (++pidx >= refP.NPoints()) pidx = 0;
311 if (u == pp.end())
return 0;
316 Int_t pidx = start_idx;
317 while (u != pp.begin())
319 if ((*u) != refP.fPnts[pidx])
322 if (++pidx >= refP.NPoints()) pidx = 0;
324 if (u == pp.begin())
return 0;
328 std::vector<int> pv(pp.size(), 0);
330 for (
auto &&u : pp) {
334 pols.emplace_back(std::move(pv));
336 return (bbox[1]-bbox[0]) * (bbox[3]-bbox[2]);
351 Int_t *seg = &bpols[2];
356 head = idxMap[
fBuff->fSegs[3*seg[0] + 1]];
357 tail = idxMap[
fBuff->fSegs[3*seg[0] + 2]];
361 head = idxMap[
fBuff->fSegs[3*seg[0] + 2]];
362 tail = idxMap[
fBuff->fSegs[3*seg[0] + 1]];
364 pp.emplace_back(head);
372 Int_t mv1 = idxMap[it.fV1];
373 Int_t mv2 = idxMap[it.fV2];
380 if (tail != pp.back()) pp.push_back(tail);
381 tail = (mv1 == tail) ? mv2 : mv1;
387 if (pp.front() == pp.back()) pp.pop_front();
410 vo1 =
fBuff->fSegs[3*
s + 1];
411 vo2 =
fBuff->fSegs[3*
s + 2];
414 if (vor1 == vor2)
continue;
416 for (
auto &seg:
segs)
420 if((vv1 == vor1 && vv2 == vor2) || (vv1 == vor2 && vv2 == vor1))
427 segs.emplace_back(vor1, vor2);
430 while (!
segs.empty())
433 pp.push_back(
segs.front().fV1);
437 while (match && !
segs.empty())
439 for (
auto k =
segs.begin(); k !=
segs.end(); ++k)
441 Int_t cv1 = (*k).fV1;
442 Int_t cv2 = (*k).fV2;
443 if (cv1 == tail || cv2 == tail)
445 pp.emplace_back(tail);
446 tail = (cv1 == tail) ? cv2 : cv1;
456 if (tail == pp.front())
488 if (surfBS < surfBP) {
510 for (
Int_t i = 0; i < nPnts - 1; ++i)
524 printf(
"REvePolygonSetProjected %d polygons\n", (
Int_t)
fPols.size());
526 for (
auto &pol :
fPols)
528 Int_t nPnts = pol.NPoints();
529 printf(
"Points of polygon %d [Np = %d]:\n", ++
cnt, nPnts);
530 for (
Int_t vi = 0; vi<nPnts; ++vi) {
548 printf(
"%d polygon of %d has %d segments \n",
pi,
fBuff->NbPols(), segN);
550 Int_t* seg = &bpols[2];
555 printf(
"(%d, %d) \n", a1, a2);
556 printf(
"ORIG points :(%f, %f, %f) (%f, %f, %f)\n",
void ProcessData(const std::vector< Double_t > &verts, const std::vector< Int_t > &polys, const Int_t n_polys)
ProcessData.
std::vector< Int_t > & RefPolyDesc()
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
std::unique_ptr< REveRenderData > fRenderData
Externally assigned and controlled user data.
virtual std::unique_ptr< TBuffer3D > MakeBuffer3D()
Create a TBuffer3D suitable for presentation of the shape.
virtual ~REvePolygonSetProjected()
Destructor.
void SetProjection(REveProjectionManager *mng, REveProjectable *model) override
This is virtual method from base-class REveProjected.
virtual void DumpPolys() const
Dump information about built polygons.
Bool_t IsFirstIdxHead(Int_t s0, Int_t s1)
Compare the two segments and check if the first index of first segment is starting.
Float_t AddPolygon(std::list< Int_t > &pp, std::list< Polygon_t > &p)
Check if polygon has dimensions above REveProjection::fgEps and add it to a list if it is not a dupli...
vpPolygon_t fPolsBS
! polygons build from TBuffer3D segments
void BuildRenderData() override
Crates representation for rendering.
void DumpBuffer3D()
Dump information about currently projected buffer.
void UpdateProjection() override
This is virtual method from base-class REveProjected.
std::list< Polygon_t > vpPolygon_t
vpPolygon_t fPolsBP
! polygons build from TBuffer3D polygons
vpPolygon_t fPols
! polygons
Float_t MakePolygonsFromBS(std::vector< Int_t > &idxMap)
Build polygons from the set of buffer segments.
std::vector< REveVector > fPnts
! reduced and projected points
void ProjectBuffer3D()
Project current buffer.
std::vector< Int_t > ProjectAndReducePoints()
Project and reduce buffer points.
Float_t PolygonSurfaceXY(const Polygon_t &poly) const
Calculate XY surface of a polygon.
void ComputeBBox() override
Override of virtual method from TAttBBox.
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
void SetDepthLocal(Float_t d) override
Set depth (z-coordinate) of the projected points.
std::unique_ptr< TBuffer3D > fBuff
Float_t MakePolygonsFromBP(std::vector< Int_t > &idxMap)
Build polygons from list of buffer polygons.
virtual void SetProjection(REveProjectionManager *mng, REveProjectable *model)
Sets projection manager and reference in the projectable object.
void SetDepthCommon(Float_t d, REveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
REveProjectionManager * fManager
REveProjectionManager Manager class for steering of projections and managing projected objects.
REveProjection * GetProjection()
REveProjection Base for specific classes that implement non-linear projections.
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e p=kPP_Full)=0
EGeoMode_e GetGeoMode() const
virtual Bool_t AcceptSegment(REveVector &, REveVector &, Float_t) const
void CopyVizParams(const REveElement *el) override
Copy visualization parameters from element el.
void BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Create cube of volume (2*epsilon)^3 at (x,y,z).
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
static constexpr double s
static constexpr double pi