polyhedron.h File Reference IntroductionDefinition of the Tpolyhedron type and the associated functions.
Definition in file polyhedron.h.
Macro Definition Documentation◆ NORMAL_SHAPE
One of the possible type of shapes. A normal shape is show and considered for collisions.
Definition at line 29 of file polyhedron.h. ◆ HIDDEN_SHAPE
One of the possible type of shapes. A hiden shape is not show but it is considered for collisions.
Definition at line 38 of file polyhedron.h. ◆ DECOR_SHAPE
One of the possible type of shapes. A decor(ation) shape is show but it is not considered for collisions.
Definition at line 47 of file polyhedron.h. ◆ OFF
One of the possible type of polyhedrons. An OFF is a general polyhedron defined by its vertices and its faces. This is a standard geomview construction.
Definition at line 60 of file polyhedron.h. ◆ COFF
One of the possible type of polyhedrons. An COFF is an OFF with color information per vertex.
Definition at line 69 of file polyhedron.h. ◆ SPHERE
One of the possible type of polyhedrons. An SPHERE is defined by a center (x,y,z) and a radius. This is a standard geomview construction.
Definition at line 80 of file polyhedron.h. ◆ CYLINDER
One of the possible type of polyhedrons. A CYLINDER is defined by two 3d points. This is not standard in geomview.
Definition at line 90 of file polyhedron.h. ◆ LINE
One of the possible type of polyhedrons. A LINE is defined by two 3d points. This is standard in geomview.
Definition at line 100 of file polyhedron.h. ◆ SEGMENTS
One of the possible type of polyhedrons. A set of SEGMENTS is defined by a set of pairs of 3d points. This is standard in geomview.
Definition at line 110 of file polyhedron.h. ◆ EMPTY_BODY
One of the possible type of polyhedrons. Used when there is an error in the definition of the object.
Definition at line 120 of file polyhedron.h. Function Documentation◆ InitPolyhedronFromFile()
Define a Tpolyhedron from a file. The default geometry file used in the CuikSuite are an variant of the geomview OFF files. Originally, the OFF files only include polygonal geometry (vertices and faces). We extended it to include also spheres, cylinders, lines and sets of 3D segments. Additionally, the CuikSuite can natively read binary STL files. Finally, if the Assimp libary is available we can read any of the file types supported by this libary. This includes, for instance, collada or blender files. The full list of supported file types is here. All those file formats are converted to a general OFF structure (vertices and faces).
Definition at line 911 of file polyhedron.c. References Tpolyhedron::color, CopyColor(), Error(), FALSE, GetFileExtension(), GetFileFullName(), HIDDEN_SHAPE, NEW, NewColor(), NO_UINT, Tpolyhedron::obj3d, ReadCylinder(), ReadGeneralMesh(), ReadLine(), ReadOFF(), ReadSegments(), ReadSphere(), ReadSTL(), Tpolyhedron::status, and TRUE. Referenced by main(). ◆ InitPolyhedronFromTriangles()
Defines an OFF object from a set of triangles.
Definition at line 989 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), Tpolyhedron::cv, Tpolyhedron::fv, Tpolyhedron::gr, Tpolyhedron::maxCoord, Tpolyhedron::ne, NEW, Tpolyhedron::nf, NO_UINT, Tpolyhedron::nv, Tpolyhedron::nvf, Tpolyhedron::obj3d, OFF, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, Tpolyhedron::status, Tpolyhedron::type, and Tpolyhedron::v. ◆ EmptyPolyhedron()
Denotes geometric objects that are defined but can not be displayed (i.e., boxes with size 0). It is not worth to add such objects to any mechanism.
Definition at line 1048 of file polyhedron.c. References EMPTY_BODY, and Tpolyhedron::type. Referenced by AddBody2Link(), and AddShape2Environment(). ◆ SimplifyPolyhedron()
Simplifies a polyhedron. Right now we only elimiate repeated vertices in (C)OFFs.
Definition at line 1053 of file polyhedron.c. References COFF, CopyColor(), Tpolyhedron::cv, Distance(), FALSE, Tpolyhedron::fv, NEW, Tpolyhedron::nf, Tpolyhedron::nv, Tpolyhedron::nvf, OFF, SameColor(), TRUE, Tpolyhedron::type, and Tpolyhedron::v. Referenced by main(). ◆ NewTriangularPrism()
Defines an triangular prism. Typically used to define triangles with some thick.
Definition at line 1109 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), CrossProduct(), Tpolyhedron::cv, DifferenceVector(), Tpolyhedron::fv, Tpolyhedron::gr, Tpolyhedron::maxCoord, Tpolyhedron::ne, NEW, Tpolyhedron::nf, NO_UINT, Normalize(), Tpolyhedron::nv, Tpolyhedron::nvf, Tpolyhedron::obj3d, OFF, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, Tpolyhedron::status, SumVectorScale(), Tpolyhedron::type, and Tpolyhedron::v. ◆ NewBox()
Defines an axis aligned box. The box is actually defined as an OFF. So, this function is just a convenient way to define OFFs for this simple shape.
Definition at line 1198 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), Tpolyhedron::cv, EMPTY_BODY, Error(), Tpolyhedron::fv, Tpolyhedron::gr, Tpolyhedron::maxCoord, Tpolyhedron::ne, NEW, Tpolyhedron::nf, NO_UINT, Tpolyhedron::nv, Tpolyhedron::nvf, Tpolyhedron::obj3d, OFF, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, Tpolyhedron::status, Tpolyhedron::type, and Tpolyhedron::v. Referenced by main(). ◆ NewSphere()
Defines a sphere (and its polyhedric approximation for collision detection).
Definition at line 1276 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), GenerateSphereOFF(), Tpolyhedron::gr, NO_UINT, Tpolyhedron::obj3d, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, SPHERE, Tpolyhedron::status, and Tpolyhedron::type. Referenced by AddLeg2World(), InitConnectLink(), InitWorldFromMolecule(), and main(). ◆ NewCylinder()
Defines a cylinder (and its polyhedric approximation for collision detection).
Definition at line 1303 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), CYLINDER, GenerateCylinderOFF(), Tpolyhedron::gr, NO_UINT, Tpolyhedron::obj3d, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, Tpolyhedron::status, and Tpolyhedron::type. Referenced by AddLeg2World(), InitConnectLink(), InitWorldFromMolecule(), and main(). ◆ NewLine()
Defines a line.
Definition at line 1333 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), GenerateCylinderOFF(), Tpolyhedron::gr, LINE, NO_UINT, Tpolyhedron::obj3d, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, Tpolyhedron::status, and Tpolyhedron::type. ◆ NewSegments()
Defines a set of segments.
Definition at line 1361 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), Tpolyhedron::cv, DECOR_SHAPE, Tpolyhedron::gr, Tpolyhedron::maxCoord, Tpolyhedron::ne, NEW, Tpolyhedron::nf, NO_UINT, Tpolyhedron::nv, Tpolyhedron::nvf, Tpolyhedron::obj3d, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, SEGMENTS, Tpolyhedron::status, Tpolyhedron::type, and Tpolyhedron::v. Referenced by InitWorldFromMolecule(). ◆ NewSpring()
Defines a polyline that resembles a spring. This is used to get nice plots in tensegrites. The spring is always aligned with the X axis and rooted at the origin. It has a initial segment, a set of loops and a final segment.
Definition at line 1412 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), Tpolyhedron::cv, DECOR_SHAPE, Error(), M_2PI, Tpolyhedron::maxCoord, Tpolyhedron::ne, NEW, Tpolyhedron::nf, NO_UINT, Tpolyhedron::nv, Tpolyhedron::nvf, Tpolyhedron::obj3d, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, SEGMENTS, Tpolyhedron::status, Tpolyhedron::type, and Tpolyhedron::v. Referenced by AddLeg2World(), and InitConnectLink(). ◆ CopyPolyhedron()
Defines a polyhedron from another polyhedron.
Definition at line 1529 of file polyhedron.c. References Tpolyhedron::center, Tpolyhedron::color, CopyColor(), Tpolyhedron::cv, Tpolyhedron::fv, Tpolyhedron::gr, Tpolyhedron::maxCoord, Tpolyhedron::ne, NEW, Tpolyhedron::nf, Tpolyhedron::nv, Tpolyhedron::nvf, Tpolyhedron::obj3d, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, Tpolyhedron::status, Tpolyhedron::type, and Tpolyhedron::v. Referenced by AddBody2Link(), and AddShape2Environment(). ◆ TransformPolyhedron()
Applies a homogenoeus transform to a polyhedron.
Definition at line 1601 of file polyhedron.c. References Tpolyhedron::center, HTransformApply(), HTransformIsIdentity(), Tpolyhedron::maxCoord, Tpolyhedron::nv, Tpolyhedron::p1, Tpolyhedron::p2, and Tpolyhedron::v. Referenced by main(). ◆ GetPolyhedronCenter()
Gets the center of the spheres. When applied to other type of polyhedrons an error is triggered.
Definition at line 1633 of file polyhedron.c. References Tpolyhedron::center, Error(), SPHERE, and Tpolyhedron::type. Referenced by body2SDF(), SolidCorrection(), and WorldAtomJacobian(). ◆ GetPolyhedronType()
Retrives the type of a polyhedron.
Definition at line 1643 of file polyhedron.c. References Tpolyhedron::type. Referenced by AddBody2Link(), AddShape2Solid(), body2SDF(), IsConnectionCable(), IsConnectionLeg(), IsConnectionSpring(), LinkNAtoms(), SolidCorrection(), and WorldAtomJacobian(). ◆ SetPolyhedronColor()
Changes the color of a polyhedron.
Definition at line 1648 of file polyhedron.c. References Tpolyhedron::color, and CopyColor(). Referenced by PrintLink(). ◆ GetPolyhedronColor()
Gets the color of a polyhedron.
Definition at line 1653 of file polyhedron.c. References Tpolyhedron::color, and CopyColor(). Referenced by body2SDF(), GetObstacleColor(), and PrintMechanism(). ◆ GetPolyhedronStatus()
Gets the status of a polyhedron (NORMAL, HIDDEN, DECOR).
Definition at line 1658 of file polyhedron.c. References Tpolyhedron::status. Referenced by AddBody2Link(), AddShape2Solid(), body2SDF(), GetLinkBodyStatus(), GetObstacleShapeStatus(), PrintLink(), PrintMechanism(), SolidCorrection(), and VisibleLink(). ◆ GetOFFInfo()
Returns the OFF information defining a shape (an OFF is the format for polyhedrons used in Geomview). Note that this can also be used for spheres and cylinders since they also have an OFF defined (a polygon approximating them). This function returns pointers to the internal structures in the polyhedron. Use them with care (for query but without modifying them)
Definition at line 1663 of file polyhedron.c. References Tpolyhedron::fv, Tpolyhedron::nf, Tpolyhedron::nv, Tpolyhedron::nvf, and Tpolyhedron::v. Referenced by AddShape2Solid(), InitPQPCD(), and InitVcollideCD(). ◆ GetPolyhedronNVertex()
Gets the number of vertexes of a polyhedron.
Definition at line 1673 of file polyhedron.c. References Tpolyhedron::nv. ◆ GetPolyhedronDefiningPoint()
Gets the coordinates of a point defining of a object. A SEGMENTS is a set of segments defined by pairs of points. In this case one of the points defining the segment is returned. A LINE is defined by two points: the initial and the end points of the cylinder. A CYLINDER is defined by two points: the initial and the end points of the cylinder. A SPHERE is defined by one point: the center of the sphere. For OFFs, all vertexes are considered defining points. If the polyhedron has less defining points than the requested number, this function triggers an error.
Definition at line 1678 of file polyhedron.c. References Tpolyhedron::center, COFF, CYLINDER, Error(), GetPolyhedronVertex(), LINE, OFF, Tpolyhedron::p1, Tpolyhedron::p2, SEGMENTS, SPHERE, and Tpolyhedron::type. Referenced by body2SDF(), GetMechanismDefiningPoint(), and SolidCorrection(). ◆ GetPolyhedronGranularity()
Returns the granularity used in the definition of the object.
Definition at line 1721 of file polyhedron.c. References Tpolyhedron::gr. Referenced by PrintLink(). ◆ GetPolyhedronRadius()
Returns the radius used in the definition of the object. This function is only defined for SPHEREs and CYLINDERs. It triggers an error if used on a OFF.
Definition at line 1726 of file polyhedron.c. References Error(), LINE, OFF, Tpolyhedron::rad, SEGMENTS, and Tpolyhedron::type. Referenced by AddShape2Solid(), body2SDF(), PrintLink(), and PrintMechanism(). ◆ GetPolyhedronVertex()
Gets the coordinates of the vertex of a polyhedron. For cylinders and spheres point on the approximating OFF are returned. If the polyhedron has less vertexes than the requested element, this function triggers an error.
Definition at line 1733 of file polyhedron.c. References Error(), Tpolyhedron::nv, and Tpolyhedron::v. Referenced by GetPolyhedronDefiningPoint(). ◆ GetPolyhedronMaxCoordinate()
Returns the maximum coordinate value (either in X, Y, or Z) used in a polyhedron. This is used in higher levels to define an over-estimate bounding-box of the mechanism. This bounding box is used to define the ranges for some of the coordinate and separating planes variables.
Definition at line 1744 of file polyhedron.c. References Tpolyhedron::maxCoord. Referenced by AddBody2Link(), and AddShape2Environment(). ◆ PlotPolyhedron()
Adds the polyhedron to a 3D geometry. Each object in a 3D scene gets an identifier that is stored in the polyhedron object for future reference.
Definition at line 1749 of file polyhedron.c. References Tpolyhedron::center, Close3dObject(), Close3dObjectNoColor(), COFF, Tpolyhedron::color, Tpolyhedron::cv, CYLINDER, DEFAULT_DICE, Tpolyhedron::fv, Tpolyhedron::gr, HIDDEN_SHAPE, LINE, Tpolyhedron::ne, Tpolyhedron::nf, Tpolyhedron::nv, Tpolyhedron::nvf, Tpolyhedron::obj3d, OFF, Tpolyhedron::p1, Tpolyhedron::p2, Plot3dObject(), Plot3dObjectWithColors(), PlotLine(), PlotSegments(), PlotSphere(), Tpolyhedron::rad, SEGMENTS, SPHERE, StartNew3dObject(), Tpolyhedron::status, Tpolyhedron::type, and Tpolyhedron::v. Referenced by PlotEnvironment(), and PlotLink(). ◆ PolyhedronPrintCenter()
Prints the center of spheres to a file. Other types of polyhedrons are non considered (they are just skiped). This is used only whent the world represents a molecule and we want to store the atom (i.e., the sphere) positions into a file. This is also useful to get particular points from configurations of mechanisms (we just put a sphere on the point and then use cuiksamples2atoms to convert configurations to samples. Note that the sphere centers are translated to gobal coordinates before printing them.
Definition at line 1788 of file polyhedron.c. References Tpolyhedron::center, HTransformApply(), SPHERE, and Tpolyhedron::type. Referenced by LinkPrintAtoms(). ◆ PolyhedronPrintCenterAndRadius()
Prints the center of spheres and the radius to a file. Other types of polyhedrons are non considered (they are just skiped). This is an auxiliary function of LinkStoreAtoms.
Definition at line 1800 of file polyhedron.c. References Tpolyhedron::center, HTransformApply(), Tpolyhedron::rad, SPHERE, and Tpolyhedron::type. Referenced by LinkStoreAtoms(). ◆ MovePolyhedron()
Moves an object previously added to a 3D scene.
Definition at line 1812 of file polyhedron.c. References HIDDEN_SHAPE, Move3dObject(), NO_UINT, Tpolyhedron::obj3d, and Tpolyhedron::status. Referenced by MoveLinkFromTransform(). ◆ SavePolyhedron()
Stores the geometic information of a polyhedron into a file. Basically, it creates a file that can be latter read using InitPolyhedronFromFile
Definition at line 1818 of file polyhedron.c. References Tpolyhedron::center, COFF, Tpolyhedron::cv, CYLINDER, Error(), Tpolyhedron::fv, GetBlue(), GetGreen(), GetRed(), LINE, Tpolyhedron::nf, Tpolyhedron::nv, Tpolyhedron::nvf, OFF, Tpolyhedron::p1, Tpolyhedron::p2, Tpolyhedron::rad, SEGMENTS, SPHERE, Tpolyhedron::type, and Tpolyhedron::v. Referenced by main(), PrintPolyhedron(), and WriteDAEMesh(). ◆ WriteDAEMesh()
This is a variant of SavePolyhedron for meshes (OFFs) only that stores the mesh in collada (dae) format.
Definition at line 321 of file polyhedron.c. References COFF, Error(), FALSE, OFF, SavePolyhedron(), TRUE, and Tpolyhedron::type. Referenced by body2SDF(). ◆ PrintPolyhedron()
Stores the polyhedron information into a file in the format valid to be read by InitWorldFromFile. Spheres and cylinders are directly written, but OFFs are stored in a separate file.
Definition at line 1884 of file polyhedron.c. References Tpolyhedron::center, COFF, Tpolyhedron::color, CreateFileName(), CYLINDER, DECOR_SHAPE, DeleteFileName(), Error(), FALSE, GetBlue(), GetFileFullName(), GetGreen(), GetRed(), HIDDEN_SHAPE, LINE, NEW, NORMAL_SHAPE, Tpolyhedron::nv, OFF, OFF_EXT, Tpolyhedron::p1, Tpolyhedron::p2, Print3Reals(), Tpolyhedron::rad, SavePolyhedron(), SEGMENTS, SPHERE, Tpolyhedron::status, TRUE, Tpolyhedron::type, and Tpolyhedron::v. Referenced by PrintEnvironment(), and PrintLink(). ◆ DeletePolyhedron()
Deletes the information stored in a Tpolyhedron and frees the allocated memory.
Definition at line 2012 of file polyhedron.c. References Tpolyhedron::cv, EMPTY_BODY, Tpolyhedron::fv, Tpolyhedron::nf, Tpolyhedron::nv, Tpolyhedron::nvf, Tpolyhedron::type, and Tpolyhedron::v. Referenced by AddLeg2World(), DeleteEnvironment(), DeleteLink(), InitConnectLink(), InitWorldFromMolecule(), and main(). |
Follow us!