37Bool_t REveGeoPolyShape::fgAutoEnforceTriangles =
kTRUE;
52 std::unique_ptr<RootCsg::TBaseMesh> res;
60 for (
UInt_t i = 0; i < b3d->NbPnts(); ++i) {
68 res.reset(RootCsg::ConvertToMesh(*b3d.get()));
73 if (matr) { mleft = *matr; mright = *matr; }
75 mleft.
Multiply(node->GetLeftMatrix());
76 auto left =
MakeGeoMesh(&mleft, node->GetLeftShape());
78 mright.
Multiply(node->GetRightMatrix());
79 auto right =
MakeGeoMesh(&mright, node->GetRightShape());
81 if (node->IsA() == TGeoUnion::Class()) res.reset(RootCsg::BuildUnion(left.get(), right.get()));
82 if (node->IsA() == TGeoIntersection::Class()) res.reset(RootCsg::BuildIntersection(left.get(), right.get()));
83 if (node->IsA() == TGeoSubtraction::Class()) res.reset(RootCsg::BuildDifference(left.get(), right.get()));
105 Int_t nv = mesh->NumberOfVertices();
108 for (
Int_t i = 0; i < nv; ++i) {
109 auto v = mesh->GetVertex(i);
113 fNbPols = mesh->NumberOfPolys();
117 for (
Int_t i = 0; i <
fNbPols; ++i) descSize += mesh->SizeOfPoly(i) + 1;
121 for (
Int_t polyIndex = 0; polyIndex <
fNbPols; ++polyIndex) {
122 Int_t polySize = mesh->SizeOfPoly(polyIndex);
126 for (
Int_t i = 0; i < polySize; ++i)
127 fPolyDesc.push_back(mesh->GetVertexIndex(polyIndex, i));
202 descSize += pols[j] + 1;
208 for (
Int_t numPol = 0, currInd = 0, j = 1; numPol <
fNbPols; ++numPol)
210 Int_t segmentInd = pols[j] + j;
211 Int_t segmentCol = pols[j];
214 Int_t s2 = pols[segmentInd];
217 segs[s2 * 3 + 1],
segs[s2 * 3 + 2]};
220 if (segEnds[0] == segEnds[2]) {
221 numPnts[0] = segEnds[1]; numPnts[1] = segEnds[0]; numPnts[2] = segEnds[3];
222 }
else if (segEnds[0] == segEnds[3]) {
223 numPnts[0] = segEnds[1]; numPnts[1] = segEnds[0]; numPnts[2] = segEnds[2];
224 }
else if (segEnds[1] == segEnds[2]) {
225 numPnts[0] = segEnds[0]; numPnts[1] = segEnds[1]; numPnts[2] = segEnds[3];
227 numPnts[0] = segEnds[0]; numPnts[1] = segEnds[1]; numPnts[2] = segEnds[2];
231 Int_t sizeInd = currInd++;
235 Int_t lastAdded = numPnts[2];
238 for (; segmentInd != end; segmentInd--) {
239 segEnds[0] =
segs[pols[segmentInd] * 3 + 1];
240 segEnds[1] =
segs[pols[segmentInd] * 3 + 2];
241 if (segEnds[0] == lastAdded) {
243 lastAdded = segEnds[1];
246 lastAdded = segEnds[0];
291 pnts + norm[2] * 3, &
fNormals[i * 3]);
302 pnts + norm[2] * 3, &
fNormals[i * 3]);
327 }
else if (
Eq(p1, p3)) {
352 return (dx < 1
e-10) && (dy < 1
e-10) && (dz < 1
e-10);
363 b.ClearSectionsValid();
379 std::map<Edge_t, Int_t> edges;
385 for (
Int_t j = 0; j < nv; ++j) {
386 Edge_t e(pd[j], (j != nv - 1) ? pd[j + 1] : pd[0]);
387 if (edges.find(
e) == edges.end()) {
388 edges.insert(std::make_pair(
e, 0));
399 Int_t si = 0, scnt = 0;
400 for (
auto &edge : edges) {
402 b.fSegs[si++] = edge.first.fI;
403 b.fSegs[si++] = edge.first.fJ;
404 edge.second = scnt++;
414 for (
Int_t j = 0; j < nv; ++j) {
415 b.fPols[pi++] = edges[
Edge_t(pd[j], (j != nv - 1) ? pd[j + 1] : pd[0])];
std::unique_ptr< RootCsg::TBaseMesh > MakeGeoMesh(TGeoMatrix *matr, TGeoShape *shape)
Function produces mesh for provided shape, applying matrix to the result.
std::vector< UInt_t > & RefPolyDesc()
void ProcessData(const std::vector< Double_t > &verts, const std::vector< UInt_t > &polys, const Int_t n_polys)
ProcessData.
REveGeoManagerHolder Exception-safe global variable holders.
void FillRenderData(REveRenderData &rd)
static Bool_t fgAutoCalculateNormals
virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const
Fill the passed buffer 3D.
std::vector< UInt_t > fPolyDesc
static void SetAutoCalculateNormals(Bool_t f)
void EnforceTriangles()
Use GLU tesselator to replace all polygons with N > 3 with triangles.
void BuildFromShape(TGeoShape *shape, Int_t n_seg=60)
Produce all polygons from normal shape.
void BuildFromComposite(TGeoCompositeShape *cshp, Int_t n_seg=60)
Produce all polygons from composite shape.
std::vector< Double_t > fNormals
virtual TBuffer3D * MakeBuffer3D() const
Create buffer 3D and fill it with point/segment/poly data.
std::vector< Double_t > fVertices
static Bool_t GetAutoCalculateNormals()
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Fill static buffer 3D.
void CalculateNormals()
CalculateNormals per polygon (flat shading)
static Bool_t GetAutoEnforceTriangles()
static Bool_t fgAutoEnforceTriangles
Int_t CheckPoints(const UInt_t *source, UInt_t *dest) const
CheckPoints.
void SetFromBuff3D(const TBuffer3D &buffer)
Set data-members from a Csg mesh.
static Bool_t Eq(const Double_t *p1, const Double_t *p2)
Test equality of points with epsilon 1e-10.
static TGeoManager * GetGeoManager()
Return static geo-manager that is used internally to make shapes lead a happy life.
void Reserve(int size_vert=0, int size_norm=0, int size_idx=0)
Reserve place for render data.
Generic 3D primitive description class.
virtual const Double_t * GetOrigin() const
virtual Double_t GetDX() const
virtual Double_t GetDZ() const
virtual Double_t GetDY() const
Class handling Boolean composition of shapes.
TGeoBoolNode * GetBoolNode() const
Matrix class used for computing global transformations Should NOT be used for node definition.
void Multiply(const TGeoMatrix *right)
multiply to the right with an other transformation if right is identity matrix, just return
Geometrical transformation package.
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix inverse
Base abstract class for all shapes.
virtual TBuffer3D * MakeBuffer3D() const
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Calculate a normal vector of a plane.
#define dest(otri, vertexptr)